home *** CD-ROM | disk | FTP | other *** search
/ Power Utilities / Power Utilities.iso / utility / pro57 / clock.doc < prev    next >
Encoding:
Text File  |  1993-11-08  |  183.3 KB  |  5,132 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.                                         CLOCK
  9.  
  10.                                      Version 3.47
  11.  
  12.  
  13.  
  14.                             CLOCK is a shareware program.
  15.                      See Appendix A for registration information.
  16.                           $10 (or $25 for full source code)
  17.                                    Ronald Q. Smith
  18.                                   11 Black Oak Road
  19.                               North Oaks, MN 55127-6204
  20.  
  21.  
  22.  
  23.  
  24.  
  25.                        (c) Copyright 1991-1993 Ronald Q. Smith
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.           CLOCK Version 3.47                                 April 10, 1993
  58.  
  59.  
  60.                                        CONTENTS
  61.  
  62.  
  63.           1  INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . .   1
  64.  
  65.           1  CLOCK.SYS - Replacement Device Driver  . . . . . . . . . .   3
  66.                1.1  Unique Clock Hardware Support . . . . . . . . . . .   3
  67.                1.2  Installing CLOCK.SYS  . . . . . . . . . . . . . . .   4
  68.                1.3  Clock Type  . . . . . . . . . . . . . . . . . . . .   8
  69.                1.4  Examples  . . . . . . . . . . . . . . . . . . . . .  11
  70.                1.5  Future Enhancements . . . . . . . . . . . . . . . .  11
  71.  
  72.           2  CLK.EXE - Clock Control Program  . . . . . . . . . . . . .  12
  73.                2.1  CLK Command . . . . . . . . . . . . . . . . . . . .  12
  74.                2.2  Format of TZ= Function  . . . . . . . . . . . . . .  24
  75.                2.3  Using CLK . . . . . . . . . . . . . . . . . . . . .  27
  76.                2.4  Examples  . . . . . . . . . . . . . . . . . . . . .  30
  77.                2.5  Errors  . . . . . . . . . . . . . . . . . . . . . .  31
  78.                2.6  Future Enhancements . . . . . . . . . . . . . . . .  31
  79.  
  80.           3  CLKDEMO.EXE  . . . . . . . . . . . . . . . . . . . . . . .  33
  81.                3.1  CLKDEMO Command Line  . . . . . . . . . . . . . . .  33
  82.  
  83.           4  IOCTL - API TO CLOCK.SYS . . . . . . . . . . . . . . . . .  34
  84.                4.1  Data Structures . . . . . . . . . . . . . . . . . .  34
  85.                4.2  clksta  . . . . . . . . . . . . . . . . . . . . . .  37
  86.                4.3  setpw . . . . . . . . . . . . . . . . . . . . . . .  40
  87.                4.4  connec  . . . . . . . . . . . . . . . . . . . . . .  41
  88.                4.5  newpw . . . . . . . . . . . . . . . . . . . . . . .  43
  89.                4.6  rstrct  . . . . . . . . . . . . . . . . . . . . . .  44
  90.                4.7  stmode  . . . . . . . . . . . . . . . . . . . . . .  47
  91.                4.8  stzone  . . . . . . . . . . . . . . . . . . . . . .  48
  92.                4.9  tdisp . . . . . . . . . . . . . . . . . . . . . . .  51
  93.  
  94.           5  CLOCK.SYS - ASSEMBLY LANGUAGE API  . . . . . . . . . . . .  55
  95.                5.1  Opening the CLOCK$ Device . . . . . . . . . . . . .  55
  96.                5.2  Sending New Values to CLOCK.SYS . . . . . . . . . .  55
  97.                5.3  Getting Current Status of CLOCK.SYS . . . . . . . .  57
  98.  
  99.           APPENDIX A:  DEFINITION OF SHAREWARE  . . . . . . . . . . . .  58
  100.  
  101.           APPENDIX B:  CLOCK TYPES  . . . . . . . . . . . . . . . . . .  60
  102.                B.1  Type 0 - PC/AT  . . . . . . . . . . . . . . . . . .  60
  103.                B.2  Type 1 - Zenith Z-18x portables, Supersport 20  . .  61
  104.                B.3  Type 2 - Various Zenith Data System PCs.  . . . . .  61
  105.                B.4  Type 3 - Memory-Mapped Clocks . . . . . . . . . . .  62
  106.                B.5  Type 4 - Direct Register I/O Bus Clock  . . . . . .  63
  107.                B.6  Type 5 - Mitsubishi 8088 PCs  . . . . . . . . . . .  64
  108.  
  109.  
  110.                                           ii
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.           CLOCK Version 3.47                                 April 10, 1993
  124.  
  125.  
  126.                B.7  Type 6 - Indirect Register I/O Bus Clock  . . . . .  66
  127.                B.8  Type 7 - Complex I/O Bus Clock  . . . . . . . . . .  67
  128.                B.9  Type 8 - Generic I/O Bus Clock  . . . . . . . . . .  68
  129.                B.10 Type 9 - Quadram I/O Bus Clock  . . . . . . . . . .  68
  130.                B.11 Type A - AT&T 6300, 6300 PLUS, 6300 WGS . . . . . .  69
  131.                B.12 Type B - Hyundai 8088 clock . . . . . . . . . . . .  70
  132.  
  133.           APPENDIX C:  REVISION HISTORY . . . . . . . . . . . . . . . .  71
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.                                          iii
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.           CLOCK Version 3.47                                 April 10, 1993
  190.  
  191.  
  192.           1  INTRODUCTION
  193.  
  194.           CLOCK consists  of two programs  that give  you complete  control
  195.           over the operation of your calendar (battery-protected) clock and
  196.           your DOS/BIOS internal  timer.  The normal DOS  mode of operation
  197.           is  to read the calendar  clock when you boot  the system and set
  198.           the internal timer.  Thereafter all read operations refer only to
  199.           the internal timer  while time setting  operations write to  both
  200.           clocks.  In levels of DOS prior to 3.3,  even time setting opera-
  201.           tions only  wrote to  the internal  timer.  In  order to  set the
  202.           calendar clock you had to run the SETUP program.
  203.  
  204.           Some of the drawbacks  to the standard  DOS clock operation  that
  205.           the CLOCK programs address are:
  206.  
  207.                ∙    There  is no  provision  to switch  time zones  without
  208.                     resetting the system time.
  209.  
  210.                ∙    DOS does not handle automatic  changes between daylight
  211.                     savings time and standard time.
  212.  
  213.                ∙    The DOS/BIOS internal timer  often drifts quite rapidly
  214.                     away  from the  time  maintained by  the more  accurate
  215.                     calendar clock.
  216.  
  217.                ∙    Even  the calendar  clock drifts  slowly away  from the
  218.                     accurate time.   DOS  provides no way  to automatically
  219.                     adjust for that drift.
  220.  
  221.                ∙    If your  battery is failing  or some other  hardware or
  222.                     software problem  messes up  the time in  your calendar
  223.                     clock, there is no way to detect that except by manual-
  224.                     ly displaying the time and checking it.
  225.  
  226.                ∙    If you have to run a program that occasionally  changes
  227.                     the time incorrectly, there  is no way to protect  your
  228.                     clock  from those  changes.   You  can  also have  this
  229.                     problem  if  you are  a parent  whose children  set the
  230.                     clock when you don't want them to, an  instructor whose
  231.                     students  reset the time, or an expert young user whose
  232.                     parents mess up your clock.
  233.  
  234.                ∙    If you need to experiment with special  times and dates
  235.                     but don't want to have to reset your clock  afterwards,
  236.                     DOS has no mechanism to help.  In order to test end-of-
  237.                     month processing for your  application, you have to set
  238.                     the date  and time,  run your tests,  and then  set the
  239.                     time and date back.
  240.  
  241.  
  242.                                           1
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.           CLOCK Version 3.47                                 April 10, 1993
  256.  
  257.  
  258.                ∙    The standard DOS and BIOS software on some PCs can miss
  259.                     the change to  a new day  when the PC  is left on  over
  260.                     midnight.
  261.  
  262.                ∙    Your clock might  not handle automatic changes to a new
  263.                     year or may not understand leap years.
  264.  
  265.                ∙    You may have an  older PC from  before the PC/AT  clock
  266.                     standardization and your vendor no longer releases  new
  267.                     versions of DOS for that PC.   You are stuck on DOS 3.2
  268.                     or earlier or you have to give up your calendar clock.
  269.  
  270.  
  271.           If any of  those circumstances cause problems for  you, CLOCK can
  272.           help.  The  two primary programs are  CLOCK.SYS and CLK.EXE.   In
  273.           addition, if you are a software developer, CLKDEMO is provided in
  274.           source code to show you how to  program the extended clock opera-
  275.           tions into your own applications.
  276.  
  277.  
  278.                CLOCK.SYS is a clock device driver (CLOCK$ device).  It
  279.                replaces the DOS internal clock driver.  CLOCK.SYS pro-
  280.                vides  for automatic  time  zone conversion.   It  also
  281.                allows you to periodically or continuously get the time
  282.                from the  calendar clock.   This can  totally eliminate
  283.                problems with missing  day changes and realtime  clocks
  284.                that are  inaccurate.   CLOCK.SYS provides support  for
  285.                many  types of  calendar clocks  including many  of the
  286.                original add-in clocks of the 8088 era.  If your  clock
  287.                is not currently supported, I want to hear from you.  I
  288.                will be happy to add it to the software.
  289.               
  290.                CLK.EXE  is a  program  that allows  you to  separately
  291.                control your  DOS/BIOS internal clock  and battery-pro-
  292.                tected calendar clock.  Most importantly,  CLK.EXE will
  293.                handle time zones and will automatically switch between
  294.                standard and  daylight savings time  for you.   It also
  295.                supports automatic adjustment for calendar clock drift,
  296.                checks  for incorrect  or unlikely  times, and  can re-
  297.                strict time changes.
  298.  
  299.                CLKDEMO.EXE is a small part of CLK.EXE that is provided
  300.                in source code (C  language) form so  that you can  see
  301.                how to add clock control to your own applications.
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.                                           2
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.           CLOCK Version 3.47                                 April 10, 1993
  322.  
  323.  
  324.           1  CLOCK.SYS - Replacement Device Driver
  325.  
  326.           CLOCK.SYS is  a device driver  that replaces the  built-in CLOCK$
  327.           device driver in DOS levels 2.1  and above.  CLOCK.SYS adds  many
  328.           functions not provided  in the standard DOS CLOCK$ device driver.
  329.           You won't see mention of the DOS CLOCK$ device driver in your DOS
  330.           user's guides.   You will see a  very small mention of  it in the
  331.           system's  programmers reference  manuals if  you are  an assembly
  332.           language developer.   It  is there and  DOS was  specifically de-
  333.           signed to  let you replace  it with one  of your own  even if the
  334.           manual doesn't tell you that.
  335.  
  336.  
  337.           1.1  Unique Clock Hardware Support
  338.  
  339.           CLOCK.SYS  was originally  written  especially for  those  people
  340.           whose  clocks  are not  supported  by new  levels of  DOS.   This
  341.           usually occurs  because your vendor stopped  providing new levels
  342.           of DOS adapted  for your computer model.  Before  the days of the
  343.           PC/AT and standard clock interfaces, DOS was usually sold direct-
  344.           ly to  hardware vendors  who customized it  for their  system and
  345.           delivered it  with the system.   In  addition, many of  the early
  346.           clocks were provided by third-party, after-market vendors who had
  347.           no idea what system it would be used in.  Since those systems and
  348.           clocks have been  out of production for a long  time, most of the
  349.           vendors have stopped  providing upgrades.  Yet most  of those PCs
  350.           will happily run  DOS 3.3 or above and especially  DOS 5.0 except
  351.           that you have to give up your calendar clock.
  352.  
  353.           CLOCK.SYS supports a wide variety of different clock hardware and
  354.           BIOS interfaces.  As far as possible, CLOCK.SYS will automatical-
  355.           ly  determine what  clock interface  to  use.   If the  automatic
  356.           determination  does  not  work  for your  system,  you  may  tell
  357.           CLOCK.SYS specifically what interface type to use.   CLOCK.SYS is
  358.           also required  by anyone  who  wants to  use CLK  as it  provides
  359.           functions not  provided by the  normal DOS CLOCK$  device driver.
  360.           CLOCK.SYS is fully  compatible with the DOS device  driver on all
  361.           modern PCs and many older ones.
  362.  
  363.           If your PC clock is not currently supported but you would like to
  364.           remove the  restrictions on  what versions  of DOS  you can  use,
  365.           please  contact me by mail or on  CompuServe.  I will be happy to
  366.           add support for your  clock.  I will need some technical informa-
  367.           tion and help from you in getting it to work so I will give you a
  368.           $0 usage license for your help.   Please see section 1.3 for  the
  369.           current list of supported clocks and Appendix B for a description
  370.           of those clocks.
  371.  
  372.  
  373.  
  374.                                           3
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.           CLOCK Version 3.47                                 April 10, 1993
  388.  
  389.  
  390.           1.2  Installing CLOCK.SYS
  391.  
  392.           To install the  device driver include the following  line in your
  393.           CONFIG.SYS file.
  394.  
  395.           Syntax    device=[d:][path\]clock.sys [type][,io_addr] [/N]
  396.  
  397.                                           or
  398.  
  399.                     device=[d:][path\]clock.sys 3[,segment[,write0,
  400.                          write1,read]] [/N]
  401.  
  402.                                           or
  403.  
  404.                     device=[d:][path\]clock.sys A[,base_year] [/N]
  405.  
  406.  
  407.           Parameters     d:
  408.                          Identifies the drive containing CLOCK.SYS.   If d:
  409.                          is not provided, the boot drive is assumed.
  410.  
  411.                     path\
  412.                          Specifies the directory containing  CLOCK.SYS.  If
  413.                          path\ is not given, the root directory is assumed.
  414.  
  415.                     CLOCK.SYS
  416.                          Is the name of the CLOCK.SYS file.  You may change
  417.                          the name  if you  wish, but you  must not  use the
  418.                          .COM or .EXE extensions.
  419.  
  420.                     type
  421.                          Is the kind of calendar clock on your system.   If
  422.                          you do not provide type, CLOCK.SYS will probe your
  423.                          system   to  determine   which  clock   you  have.
  424.                          CLOCK.SYS is  usually able  to detect the  type of
  425.                          calendar clock  without trouble.  It  is possible,
  426.                          however, that you have some other hardware in your
  427.                          system that  could fool CLOCK.SYS.   For that rea-
  428.                          son, you might need to provide the type  of clock.
  429.                          See section  1.3 and Appendix B  for more informa-
  430.                          tion about the clock types.
  431.  
  432.                     io_addr
  433.                          Is  the I/O  bus address  of your  clock hardware.
  434.                          Some  of the  types of  clocks that  are supported
  435.                          were set  up at a  wide variety of  I/O addresses.
  436.                          CLOCK.SYS  probes  all the  commonly used  I/O ad-
  437.                          dresses for  these clocks.   However, you  or your
  438.  
  439.  
  440.                                           4
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.           CLOCK Version 3.47                                 April 10, 1993
  454.  
  455.  
  456.                          vendor may have installed your clock at an address
  457.                          that CLOCK.SYS  doesn't know about.   By providing
  458.                          the  address, you  make it  much more  likely that
  459.                          CLOCK.SYS will correctly find your clock.  Even if
  460.                          you  don't know what type  of clock you have, pro-
  461.                          viding the I/O address may be enough for CLOCK.SYS
  462.                          to determine which one it is.  io_addr is current-
  463.                          ly  used with clock  types 4, 6,  7, 8, 9,  and B.
  464.                          Normally this is 240, 2C0, or 340 for types 4,  6,
  465.                          and 7.  It is 210 or 310 for type 9.  And it is E0
  466.                          for type B.  All numbers are in hex.  For example,
  467.                          an AST Research clock might be:
  468.  
  469.                          device=[d:][path\]clock.sys 4,2C0
  470.  
  471.                          If  you do  not  specify the  "io_addr", CLOCK.SYS
  472.                          will try to determine the correct address by prob-
  473.                          ing.
  474.  
  475.                          If you are sure that you have an I/O clock but you
  476.                          are not sure  which one it is, specify  type 8 and
  477.                          supply the io_addr  if possible.  Type 8  does not
  478.                          represent a specific clock.  Rather it attempts to
  479.                          determine whether your clock is a type 4, 6, 7, 9,
  480.                          or  B using a  sequence of tests  similar to those
  481.                          used by some  of the I/O  clock vendors to  figure
  482.                          out what kind of clock you have.
  483.  
  484.                     If you  have a  memory mapped  clock, you  may use  the
  485.                     second format to specify the addresses to be used.   If
  486.                     you don't know the addresses, CLOCK.SYS will attempt to
  487.                     determine them by probing.
  488.  
  489.                     segment
  490.                          Is  the base  address  used to  access the  clock.
  491.                          Usually your  documentation will give  the segment
  492.                          address as four  hex digits such as  FE00 or F000.
  493.                          Some addresses may be less than four digits (e.g.,
  494.                          70).   Other  documentation may show  addresses in
  495.                          the  form aaaa:bbbb.    In this  case the  segment
  496.                          address is  the aaaa  value.  Sometimes  these ad-
  497.                          dresses  are written as  0xaaaa, aaaah,  aaaaH, or
  498.                          0Xaaaa.  In all of these forms there is a 2- to 4-
  499.                          digit hex number that is the segment address.
  500.  
  501.                     write0
  502.                          Is  the offset used to write 0 bits.  It must also
  503.                          be a hex  address and may be 0,  F002, or anything
  504.  
  505.  
  506.                                           5
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.           CLOCK Version 3.47                                 April 10, 1993
  520.  
  521.  
  522.                          else the vendor chose.  If the addresses are given
  523.                          in the aaaa:bbbb form,  use the bbbb.   With these
  524.                          clocks, you  read and  write the clock  by reading
  525.                          the  memory addresses.   For example,  reading ad-
  526.                          dress segment:write0 results in writing a zero bit
  527.                          to the  clock.  Writing an  appropriate length se-
  528.                          quence of zero and one bits sets the clock.
  529.  
  530.                     write1
  531.                          Is the offset used to write 1 bits.
  532.  
  533.                     read
  534.                          Is the offset used to read bits.
  535.  
  536.                          If your  documentation gives  the segment  address
  537.                          but isn't  clear about the  offsets, just  specify
  538.                          the  segment address  and CLOCK.SYS  will try  all
  539.                          offset combinations that it knows about.
  540.  
  541.                          If you specify one of the offsets, you must speci-
  542.                          fy them all.
  543.  
  544.                     The third format is used with the AT&T 6300 clocks.
  545.  
  546.                     base_year
  547.                          Is used for the AT&T 6300 clocks (type=A).   Dates
  548.                          prior to that year or more than 7 years after that
  549.                          year will  not be handled  correctly.  If  no base
  550.                          year is specified, 1992  will be used.   Dates be-
  551.                          tween the start of  the base year  and the end  of
  552.                          the seventh year later are handled (e.g., 1992-1-1
  553.                          until 1999-12-31).
  554.  
  555.                     /N
  556.                          Indicates that  you do  not want CLOCK.SYS  to at-
  557.                          tempt  to detect  missed date  changes.   Normally
  558.                          CLOCK.SYS  will  try to  detect  when  a date  has
  559.                          changed that was not  reported by the BIOS.   This
  560.                          usually happens  when a  program  is running  past
  561.                          midnight and calls the BIOS to read the time rath-
  562.                          er than calling  DOS.  That program sees the date-
  563.                          change  indication   from   the   BIOS   and   DOS
  564.                          (CLOCK.SYS) never gets a chance to change the day.
  565.                          However,  the logic  that  CLOCK.SYS uses  can  be
  566.                          fooled by  programs that change the  time with di-
  567.                          rect calls  on the BIOS  and may advance  the date
  568.                          incorrectly.  This is very rare,  but if your date
  569.  
  570.  
  571.  
  572.                                           6
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.           CLOCK Version 3.47                                 April 10, 1993
  586.  
  587.  
  588.                          advances unexpectedly or by more than one day, you
  589.                          may want to use this option.
  590.  
  591.           Notes     DOS interfaces                    ______________
  592.                     All DOS  DATE and  TIME commands and  all DOS  date and
  593.                     time system calls will  operate with no apparent change
  594.                     to you  or any program.   Unless you  have used  CLK to
  595.                     change the time handling,  your clocks are handled just
  596.                     as DOS would handle them.
  597.  
  598.                     Dates and leap years                    ____________________
  599.                     CLOCK.SYS supports all valid DOS dates from 1980-1-1 to
  600.                     2079-12-31.   It supports dates to  2099-12-31 for many
  601.                     of the clocks.  CLOCK.SYS also handles year changes and
  602.                     leap years automatically for  clock types that don't do
  603.                     it themselves.
  604.  
  605.                     Time zones and daylight savings time                    ____________________________________
  606.                     CLOCK.SYS in conjunction  with CLK.EXE provides support
  607.                     for multiple  time zones  and automatic conversion  be-
  608.                     tween daylight  savings time  and standard time  at the
  609.                     appropriate  times  of  the  year.   For  this  reason,
  610.                     CLOCK.SYS  may be  of great  use  to you  even if  your
  611.                     version of DOS already supports your clock correctly.
  612.  
  613.                     Clock synchronization                    _____________________
  614.                     Normally,  CLOCK.SYS operates  identically  to the  DOS
  615.                     CLOCK$ device driver.   At boot it  sets the DOS  clock
  616.                     from the calendar clock.  Any time you change the  date
  617.                     or time it writes to both clocks.
  618.  
  619.                     With CLK.EXE you  have several other  options.  If  you
  620.                     have  specified a  time zone  and offset  with CLK.EXE,
  621.                     CLOCK.SYS will  adjust all times read  from and written
  622.                     to the calendar clock by the time zone offset.  You can
  623.                     also set it to read the calendar clock rather than  the
  624.                     DOS  clock for  some  or all  time  requests to  ensure
  625.                     continued synchronization  of the two clocks.   You can
  626.                     also  totally separate the two clocks  so that DOS time
  627.                     and  date functions  only read  and write  the DOS/BIOS
  628.                     internal clock.
  629.  
  630.                     Time setting limits                    ___________________
  631.                     CLK.EXE can tell CLOCK.SYS to apply limits to the  time
  632.                     changes  that it  will  accept or  stop accepting  time
  633.                     changes at all.  For example, you can tell CLOCK.SYS to
  634.                     accept no  changes that  would set the  clock backward.
  635.                     You can also inhibit all changes.
  636.  
  637.  
  638.                                           7
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.           CLOCK Version 3.47                                 April 10, 1993
  652.  
  653.  
  654.                     Password Protection                    ___________________
  655.                     CLK.EXE  can establish  a  password to  control  future
  656.                     changes to the time  zone, connection, and time setting
  657.                     limits.   Once  the password  is  set, all  attempts to
  658.                     change those  values will simply be  ignored unless the
  659.                     correct  password  is supplied.    You  may change  the
  660.                     daylight  versus standard time  flag and the continuous
  661.                     time display without knowing the password.
  662.  
  663.                     Continuous Time Display                    _______________________
  664.                     CLK.EXE can tell CLOCK.SYS to display the time continu-
  665.                     ously at any position on your screen.  You specify  the
  666.                     cursor coordinates, display  attributes, and 12-hour or
  667.                     24-hour mode  and  CLOCK.SYS will  update  the  display
  668.                     every second.
  669.  
  670.                     Saving Settings Across Boots                    ____________________________
  671.                     With  CLK.EXE  you  can   save  the  current  state  of
  672.                     CLOCK.SYS  at any time  in a form  that can be  used on
  673.                     your next boot.  You can set up your time zone, setting
  674.                     limits, connection mode, continuous display, and  pass-
  675.                     word and then save  a new version  of CLOCK.SYS.   This
  676.                     new  version  will  automatically  start  running  with
  677.                     without having to scan for your clock type and with all
  678.                     your standard state automatically in effect.
  679.  
  680.  
  681.           1.3  Clock Type
  682.  
  683.           There  are almost as many different  implementations of PC clocks
  684.           as there are different types of PCs.  Until the PC/AT came along,
  685.           there  was no standard for  battery-protected clocks, and each PC
  686.           and add-in vendor was likely to implement them differently.  With
  687.           the PC/AT a standard and documented interface for such clocks was
  688.           provided.   Since that  time, most  PCs have  followed the  PC/AT
  689.           standard.   It is  earlier PCs, especially  8088 PCs,  that don't
  690.           follow the standard.  Since these  are early PCs, there is also a
  691.           high probability that the vendor is  no longer providing modified
  692.           versions of  DOS with  built-in support for  their clocks.   Most
  693.           add-in clock vendors never did provide a modified DOS and you had
  694.           to manage  your clock  with utility  programs.   This leaves  you
  695.           faced with the choice  between staying with  an early version  of
  696.           DOS or giving up your clock.
  697.  
  698.           CLOCK.SYS is  intended to  free you from  those limitations.   It
  699.           will work with  all versions of  DOS from 2.10  through 5.00  and
  700.           undoubtedly beyond.  It  also attempts to automatically determine
  701.           what kind of clock you have  and install the correct support  for
  702.  
  703.  
  704.                                           8
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.           CLOCK Version 3.47                                 April 10, 1993
  718.  
  719.  
  720.           it.  However, there are often enough differences between PCs that
  721.           the automatic determination  may not  find anything  or may  even
  722.           make  the wrong choice.   To give you more  control of the situa-
  723.           tion, you may specify the clock interface by giving an  interface
  724.           number.
  725.  
  726.           It will  not always be  easy to decide  what interface  number to
  727.           use.  You will  at least need  some technical information on  how
  728.           your  clock works or on  the BIOS calls used  to control the bat-
  729.           tery-protected clock.  If you find a description below that seems
  730.           to  match, give it a try.  The  most that should go wrong is that
  731.           your time and date will be set incorrectly,  but then they proba-
  732.           bly weren't working anyhow.
  733.  
  734.           If you aren't sure what interface to use or if you are  sure that
  735.           your clock is not  supported, LET ME KNOW.  I WOULD LIKE TO HELP.
  736.           You can help me make CLOCK.SYS better for everyone.  I would even
  737.           like to  hear from you  if CLOCK.SYS  did work  for you and  your
  738.           clock isn't  currently listed.   I would like  to be able  to add
  739.           your PC manufacturer and  model number to  the supported list  so
  740.           others know what to use.  If CLOCK.SYS did not work for you, I am
  741.           interested in  making the changes so  that it does work.   If you
  742.           can  provide me with the  necessary technical information, I will
  743.           make the changes.
  744.  
  745.           Usually,  a technical  reference  manual with  hardware and  BIOS
  746.           interfaces is the best source.  Even if you  don't have one, your
  747.           original  hardware  vendor may  be  willing  to send  you  enough
  748.           information  to allow  you  to program  the clock.   If  all else
  749.           fails, we may even  be able to use an old copy of  DOS or a clock
  750.           setting utility to  figure out how it works.   Before we do that,
  751.           check  your license to be sure that it is not forbidden to disas-
  752.           semble the software to see how the clock works.  
  753.           The following table shows the  systems that have been  determined
  754.           to  work with existing  clock types.   If your  system is  in the
  755.           list,  try the clock type indicated.  If not, look through Appen-
  756.           dix B which tells you about  the characteristics of each type  of
  757.           clock and see if anything seems to match your system type.
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.                                           9
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.           CLOCK Version 3.47                                 April 10, 1993
  784.  
  785.  
  786.                    ╔═══════════════════════════╤══════════════════════════╗
  787.                    ║     SYSTEM                │  BLOCK TYPE              ║
  788.                    ╟───────────────────────────┼──────────────────────────╢
  789.                    ║     Amstrad PC1521DD      │  0                       ║
  790.                    ╟───────────────────────────┼──────────────────────────╢
  791.                    ║     AST Research          │  8 (4, 6, or 7) See dis- ║
  792.                    ║       Six-Pack            │  cussion above and in    ║
  793.                    ║       I/O Plus            │  Appendix B              ║
  794.                    ║       etc.                │                          ║
  795.                    ╟───────────────────────────┼──────────────────────────╢
  796.                    ║     AT&T 6300             │  A                       ║
  797.                    ╟───────────────────────────┼──────────────────────────╢
  798.                    ║     Hyundai 8088          │  B                       ║
  799.                    ╟───────────────────────────┼──────────────────────────╢
  800.                    ║     IBM PC/AT and most    │  0                       ║
  801.                    ║     PCs since then.       │                          ║
  802.                    ╟───────────────────────────┼──────────────────────────╢
  803.                    ║     Leading Edge Model D  │  5                       ║
  804.                    ╟───────────────────────────┼──────────────────────────╢
  805.                    ║     Mitsubishi 8088       │  5                       ║
  806.                    ╟───────────────────────────┼──────────────────────────╢
  807.                    ║     Quadram Corp.         │  9                       ║
  808.                    ║       QuadCard            │                          ║
  809.                    ║       QuadCard II         │                          ║
  810.                    ║       QuadCard 512+       │                          ║
  811.                    ╟───────────────────────────┼──────────────────────────╢
  812.                    ║     SMT No-Slot Clock     │  3                       ║
  813.                    ╟───────────────────────────┼──────────────────────────╢
  814.                    ║     Sperry PC-1           │  5                       ║
  815.                    ╟───────────────────────────┼──────────────────────────╢
  816.                    ║     Sperry PC/HT          │  5                       ║
  817.                    ╟───────────────────────────┼──────────────────────────╢
  818.                    ║     Tandy 1200HD          │  4                       ║
  819.                    ╟───────────────────────────┼──────────────────────────╢
  820.                    ║     Vendex Turbo-888-XT   │  4                       ║
  821.                    ╟───────────────────────────┼──────────────────────────╢
  822.                    ║     Zenith Supersport 20  │  1                       ║
  823.                    ╟───────────────────────────┼──────────────────────────╢
  824.                    ║     Zenith Z-18x          │  1                       ║
  825.                    ╚═══════════════════════════╧══════════════════════════╝
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.                                           10
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.           CLOCK Version 3.47                                 April 10, 1993
  850.  
  851.  
  852.           1.4  Examples
  853.  
  854.           For almost everyone, the only format you ever need to use is:
  855.                device=[d:][path\]clock.sys
  856.  
  857.           If CLOCK.SYS is in  the root directory of your boot  device, this
  858.           is:
  859.                device=clock.sys
  860.  
  861.           CLOCK.SYS will  quite happily load  into the upper  memory blocks
  862.           (UMBs)  provided by DOS 5.0 and by other software.  With DOS 5.0,
  863.           you might use:
  864.                devicehigh=clock.sys
  865.  
  866.           With some memory managers you can even load CLOCK.SYS into  upper
  867.           memory blocks on earlier levels of  DOS.  See your manual for the
  868.           commands to use.  Some of these  memory managers will create UMBs
  869.           on 8088  and 80286 systems.   CLOCK.SYS  loads and  runs high  on
  870.           those systems as well.
  871.  
  872.           With a memory mapped clock that uses an address combination  that
  873.           CLOCK.SYS doesn't search automatically  and with CLOCK.SYS stored
  874.           in the C:\UTILITY directory, you might use:
  875.                device=c:\utility\clock.sys 3,ffff,f000,f004,f008
  876.           Please note that the memory addresses chosen for this example are
  877.           not likely to match those of your clock and you should substitute
  878.           the addresses appropriate to your clock.
  879.  
  880.           If you have an  I/O clock with the same interface  as the Quadram
  881.           Corp. clock but a different I/O address, you might use:
  882.                device=clock.sys 9,3fc
  883.           if your I/O base address were 3fc.
  884.  
  885.           If you have one of the AT&T 6300 system types and you occasional-
  886.           ly need to set your clock prior to 1992-1-1, you might use:
  887.                device=clock.sys a,1988
  888.  
  889.           1.5  Future Enhancements
  890.  
  891.           Of course,  I hope  to add  more clocks as  people ask  for them.
  892.           Those old PCs are still good for a lot of what we do even if they
  893.           are sometimes relegated to a secondary status.
  894.  
  895.           There are no other outstanding enhancements currently planned for
  896.           CLOCK.SYS.
  897.  
  898.  
  899.  
  900.  
  901.  
  902.                                           11
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.           CLOCK Version 3.47                                 April 10, 1993
  916.  
  917.  
  918.           2  CLK.EXE - Clock Control Program
  919.  
  920.           CLK gives you complete control over the operation of the calendar
  921.           clock and  DOS/BIOS clock.   You can  operate them  separately or
  922.           together.  You  can establish time  zones, daylight savings  time
  923.           rules, automatic adjustment, synchronization rules, and more.
  924.  
  925.  
  926.           2.1  CLK Command
  927.  
  928.           Syntax    clk [function] [function ...] [/I[file]] [/?]
  929.  
  930.                               or in full form
  931.  
  932.                     clk [A=±sss.cc] [C=A|D|R|W] [D=[N][x,y,a[,12|,24]]
  933.                          [L=...] [M=...] [R=A|B-hh:mm:ss|F+hh:mm:ss|N|R]
  934.                          [S=C|D]    [TZ=...]    [W=-back,+forward]     [/B]
  935.                          [/I[file][,C]]  [/M[file][,C]] [/P[N]]  [/S[file]]
  936.                          [/?]
  937.  
  938.           Parameters     function
  939.                          There  are many  functions that  may be  used with
  940.                          CLK.EXE and  they are discussed  in the  following
  941.                          paragraphs.   You may use any  number of functions
  942.                          on  a single command  line and  they will  be pro-
  943.                          cessed  in  the order  in  which  you enter  them.
  944.                          However, if  any error is discovered in any of the
  945.                          functions, none of them are processed.  Thus, 
  946.                               clk c=r tz=:est
  947.                          is the same as the two command lines:
  948.                               clk c=r
  949.                               clk tz=:est
  950.                          except that an error in either of the functions in
  951.                          the first  example cause  the whole command  to be
  952.                          ignored.
  953.  
  954.                          The case (upper  or lower) of any  of the function
  955.                          names, options,  or values  is ignored  except for
  956.                          the TZ  function's time  zone names.   Even there,
  957.                          the case is not used.  It is simply preserved  for
  958.                          later display.
  959.  
  960.                          You can display a  help message about any function
  961.                          or option  by immediately  following the  function
  962.                          letter or  option letter with ?.  Thus M? displays
  963.                          help about  the M= function and  /I? displays help
  964.                          about the I  option.  /?  displays a help  message
  965.                          about the CLK command line.
  966.  
  967.  
  968.                                           12
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.           CLOCK Version 3.47                                 April 10, 1993
  982.  
  983.  
  984.                     none
  985.                          If no function or option is provided, CLK displays
  986.                          the current  state of  operation of  CLOCK.SYS and
  987.                          the current time from  both the calendar clock and
  988.                          the DOS/BIOS clock.
  989.  
  990.                          If you have used CLK to set a time  zone (TZ func-
  991.                          tion), the current time zone name and offset value
  992.                          are  displayed.     These  values   are  saved  in
  993.                          CLOCK.SYS so that they may  be used for time func-
  994.                          tions.
  995.  
  996.                          The connection state of the clocks (C function) is
  997.                          displayed as is the current restrictions  (R func-
  998.                          tion) on clock changes.
  999.  
  1000.                          All uses  of CLK  (except  errors and  /?) end  by
  1001.                          displaying  the same information.  You always know
  1002.                          the state of your two clocks after execution.
  1003.  
  1004.                     A=±sss.cc
  1005.                          The Adjust function is used to set a daily adjust-
  1006.                          ment factor in seconds and 100ths of seconds.
  1007.  
  1008.                          This function assumes that you have some knowledge
  1009.                          of the  rate at  which your calendar  clock drifts
  1010.                          with respect to "real"  time.  Presumably you have
  1011.                          periodically  set your clock  using a program that
  1012.                          calls the Naval Observatory  or NIST and noted the
  1013.                          difference  over time.    Some such  programs will
  1014.                          help you to calculate the drift rate.  You can get
  1015.                          a very good adjustment from a decent quartz watch.
  1016.  
  1017.                          The value may be a positive or  negative number in
  1018.                          the range  -326.99 to +326.99 seconds  per day but
  1019.                          reasonable values are likely to be a fraction of a
  1020.                          second.
  1021.  
  1022.                          The first time  you use A=, your clock  is not ad-
  1023.                          justed.  The  value of A and the  current time are
  1024.                          saved in  a file  for later  use.   Later you  can
  1025.                          choose to run CLK with the /I option to invoke the
  1026.                          file.  The elapsed  time since the last adjustment
  1027.                          (or the time you last changed A) in days and frac-
  1028.                          tions is multiplied by  A to calculate any adjust-
  1029.                          ment that needs to be applied.  Only whole seconds
  1030.                          of adjustment are applied.
  1031.  
  1032.  
  1033.  
  1034.                                           13
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.           CLOCK Version 3.47                                 April 10, 1993
  1048.  
  1049.  
  1050.                          The A=  function only sets the  adjustment factor.
  1051.                          The  actual adjustment  is carried  out by  the L=
  1052.                          function.   You don't have  to enter the  L= func-
  1053.                          tion.  CLK will do that for you the first time you
  1054.                          use A=  and will keep  it up  to date as  it later
  1055.                          makes adjustments.
  1056.  
  1057.                          NOTE:  Do not  use the A=  function with the  AT&T
  1058.                          6300 clocks  (Type A) or the  Quadram clocks (Type
  1059.                          9).  They only  permit the time to  be set to  the
  1060.                          nearest minute.
  1061.  
  1062.                     C=A
  1063.                          Connects the  two clocks for All  operations.  All
  1064.                          read operations go directly to the calendar clock.
  1065.                          The calendard clock is  read, the time is adjusted
  1066.                          for any time zone offset, and the adjusted time is
  1067.                          written to the DOS clock and returned to the call-
  1068.                          er.   With this function, your  calendar clock es-
  1069.                          sentially becomes  the only  clock.  However,  the
  1070.                          DOS clock is set each time so that any application
  1071.                          reading the clock  directly (without going through
  1072.                          DOS) sees the  same time that DOS reports.   It is
  1073.                          unwise to use this function  if your clock is slow
  1074.                          (some I/O clocks and some memory-mapped clocks) or
  1075.                          if it  only increments  in units of  seconds (most
  1076.                          clocks).  Any time zone offset is applied to reads
  1077.                          and writes.
  1078.  
  1079.                     C=D
  1080.                          Disconnects  the two  clocks.   Any change  of the
  1081.                          date  and time  will  affect the  DOS clock  only.
  1082.                          Reads also use the DOS  clock only.  This function
  1083.                          allows you  to perform  any operation on  the time
  1084.                          without affecting  your  calendar clock.    It  is
  1085.                          useful for dealing with ill-behaved programs  that
  1086.                          need to  change the time and  for testing programs
  1087.                          at different dates and  times.  You can  later use
  1088.                          the C=R, C=A,  or other functions  to re-establish
  1089.                          the  value in  your  DOS clock  from the  calendar
  1090.                          clock.
  1091.  
  1092.                     C=R
  1093.                          Connects the  two clocks for  writing and periodic
  1094.                          Reading.   This  function  may be  used when  your
  1095.                          clocks  drift slowly  with respect to  each other.
  1096.                          If the time has  not been read  for about 10  sec-
  1097.                          onds, the calendar clock will be read, adjusted by
  1098.  
  1099.  
  1100.                                           14
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.           CLOCK Version 3.47                                 April 10, 1993
  1114.  
  1115.  
  1116.                          the offset  if any, and the  adjusted time written
  1117.                          to the DOS clock and returned to the caller.  This
  1118.                          periodic Read  assures you  that the  clocks never
  1119.                          get  very  far out  of  synchronization with  each
  1120.                          other.    Some calendar  clocks take  a relatively
  1121.                          long time  to read and  most don't have  100ths of
  1122.                          seconds.  By only  reading the calendar clock when
  1123.                          no other time request has occurred in the last  10
  1124.                          seconds,  we minimize  both  the overhead  and any
  1125.                          visibility of time jumps.
  1126.  
  1127.                     C=W
  1128.                          Connects  the two clocks for Writing.  This is the
  1129.                          default  mode of  operation and  is the  same mode
  1130.                          that the DOS CLOCK$  device driver supports as its
  1131.                          only mode.  Reading the time is served by the  DOS
  1132.                          clock.  Writing  the time sets both clocks.   If a
  1133.                          time zone  offset has  previously been  specified,
  1134.                          all writes to  the clock are adjusted  so that the
  1135.                          calendar  clock remains  on  the base  time.   For
  1136.                          example,  if the calendar clock is  set to UTC and
  1137.                          you specify that you want to use CST which has  an
  1138.                          offset of 6 hours from UTC, all writes of the time
  1139.                          will have 6 hours added  to them before writing to
  1140.                          the  calendar clock.   Thus the DOS  clock and the
  1141.                          calendar clock remain at a constant time offset.
  1142.  
  1143.                     D=N
  1144.                          The D=  function controls  a continuous  time dis-
  1145.                          play.  D=N turns off the continuous display.
  1146.  
  1147.                     D=x,y,a[,12|,24]
  1148.                          Starts a continuous  time display at cursor  posi-
  1149.                          tion x,y  with display attribute a.   Cursor posi-
  1150.                          tion 0,0  is the upper left corner  of the screen.
  1151.                          The typical screen format  runs from 0,0 to 79,24.
  1152.                          The display  attribute is a  two-digit hex  number
  1153.                          that gives the  background and foreground  colors.
  1154.                          The high-order digit is the background color (0 to
  1155.                          7 usually)  and the  low-order digit is  the fore-
  1156.                          ground  or character color (0  to F).  The default
  1157.                          display is  a 24-hour clock in  the form HH:MM:SS.
  1158.                          If you add  the ",12", the display will  use a 12-
  1159.                          hour clock.  No AM or PM indication is given.
  1160.  
  1161.                          D=72,24,79,12  will place the display at the right
  1162.                          edge of the  last line of most screens.   The text
  1163.  
  1164.  
  1165.  
  1166.                                           15
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.           CLOCK Version 3.47                                 April 10, 1993
  1180.  
  1181.  
  1182.                          will be in  bright blue on a  white background and
  1183.                          the hours will run from 12 through 11.
  1184.  
  1185.                          D= by  itself will resume a  previous display that
  1186.                          was turned  off by D=N.   You  do not have  to re-
  1187.                          enter all the values.
  1188.  
  1189.                          The D=  functions should  not  be used  if CLK  is
  1190.                          executed from  within Windows.   If you try  to do
  1191.                          so,  you will  received  an error  message.   This
  1192.                          avoids  a hung  system  which would  occur if  CLK
  1193.                          didn't check.
  1194.  
  1195.                     L=YYYY-MM-DD,hh:mm:ss,±sss.cc
  1196.  
  1197.                          The L= function is not intended to be used on  the
  1198.                          command line, but will  be accepted if you provide
  1199.                          it.   The L= function  is normally created  by CLK
  1200.                          and saved  in the  CLK.INI file  for later  use in
  1201.                          processing adjustments.  The  date and time of the
  1202.                          last adjustment (or the  most recent time you gave
  1203.                          an A= function  on the command line) are  given by
  1204.                          the YYYY-MM-DD,hh:mm:ss.   Any non-digit except  a
  1205.                          space may  separate the sub-fields.   The date and
  1206.                          time must be followed by  a comma and any  adjust-
  1207.                          ment remainder.   The adjustment  remainder is  in
  1208.                          the same form as the value for the A= function but
  1209.                          will usually be a fraction of a second.  It is the
  1210.                          adjustment  that was  left over  the last  time an
  1211.                          adjustment was  actually  made  since  only  whole
  1212.                          seconds of changes are made to the clock.
  1213.  
  1214.                          The L= function triggers an  adjustment if needed.
  1215.                          Generally,  it will  follow the  A=  function that
  1216.                          sets the  adjustment factor.  Both  of these func-
  1217.                          tions normally appear in the CLK.INI file.
  1218.  
  1219.                          The L= function  may also be used by  itself to do
  1220.                          simple arithmetic  on the clocks.   Use it  on the
  1221.                          command line with any earlier date and time and an
  1222.                          adjustment of the number  of seconds (positive  or
  1223.                          negative) that you  want added to the  clock.  The
  1224.                          change will  be made and the  last adjustment time
  1225.                          set to the current time.  For example, 
  1226.                               clk l=1990-1-1,0:0:0,-4
  1227.                          will subtract 4 seconds from the clocks.
  1228.  
  1229.  
  1230.  
  1231.  
  1232.                                           16
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.           CLOCK Version 3.47                                 April 10, 1993
  1246.  
  1247.  
  1248.                     M=±sss.cc,YYYY-MM-DD,hh:mm:ss
  1249.                          The M= function is used to  help you calculate the
  1250.                          automatic adjustment  A= value  for your  calendar
  1251.                          clock.  The M= function is used to enter the manu-
  1252.                          al adjustments that you make to the clock in addi-
  1253.                          tion to the automatic adjustments.  The ±sss.cc is
  1254.                          the amount  of  manual adjustment  that  you  have
  1255.                          made.  This may be adjustments made by setting the
  1256.                          clock with the DOS  DATE and TIME commands or  ad-
  1257.                          justments  made by  a time  setting program.   The
  1258.                          YYYY-MM-DD,hh:mm:ss  is the date and time at which
  1259.                          the  adjustment was  made.   It is  very important
  1260.                          that  the date and  time be given  with respect to
  1261.                          the calendar clock  and not the DOS clock, if dif-
  1262.                          ferent.  If  you do not supply the  date and time,
  1263.                          the current  date  and time  will be  used.   This
  1264.                          should be  sufficiently accurate if you  just com-
  1265.                          pleted making the adjustement.
  1266.  
  1267.                          The first M= value that you enter is used only  to
  1268.                          set a base date and time.  Then as you enter addi-
  1269.                          tional values in the  future, CLK will calculate a
  1270.                          new value for  the A= function by adding the aver-
  1271.                          age manual  adjustment per  day to the  current A=
  1272.                          value.  Up to  8 values are  saved in the  CLK.INI
  1273.                          file (or  other file that you specify).   The more
  1274.                          values you provide and the longer the time period,
  1275.                          the  more accurate  the adjustment  will be.   For
  1276.                          example, if you can  only determine the adjustment
  1277.                          to the  nearest second  (likely), you may  want to
  1278.                          have a  week or  more between  manual adjustments.
  1279.                          The only  restriction is  that the first  and last
  1280.                          manual adjustement must be within one year of each
  1281.                          other.  If  you enter more than 8,  the oldest two
  1282.                          adjustement  values  are collapsed  into  a single
  1283.                          value.
  1284.  
  1285.                          Supplying a new A=  value, presumably based on the
  1286.                          calculations from CLK,  deletes all the  M= values
  1287.                          from the file.  You may either specify a /I option
  1288.                          to specify the  file and read all the functions in
  1289.                          the file, a /M option to specify the file and only
  1290.                          read the  M= functions, or CLK  will automatically
  1291.                          specify the /M  option for you  (but it will  only
  1292.                          know to look for CLK.INI in the directory contain-
  1293.                          ing CLK.EXE).  You may  also edit the M= functions
  1294.                          in the file and  use the /M option to  force a re-
  1295.                          calculation.
  1296.  
  1297.  
  1298.                                           17
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.           CLOCK Version 3.47                                 April 10, 1993
  1312.  
  1313.  
  1314.                          When  CLK calculates  a new  adjustment value,  it
  1315.                          tries to determine if any of the M= values are out
  1316.                          of line  with the  rest of  the values.   It  will
  1317.                          ignore, but  provide an  error message, if  any of
  1318.                          the values are  too far away from all  of the oth-
  1319.                          ers.  CLK calculates an average and standard devi-
  1320.                          ation  and ignores all  values (of  adjustment per
  1321.                          day) that are more than 2 standard deviations from
  1322.                          the average.
  1323.  
  1324.                     R=A
  1325.                          The R= function sets restrictions on time changes.
  1326.                          R=A  inhibits All time changes.  When this mode is
  1327.                          set, all  attempts to change the  time are ignored
  1328.                          by CLOCK.SYS.  This  includes time changes attemp-
  1329.                          ted by CLK including time adjustments.  See R=N.
  1330.  
  1331.                     R=B-hh:mm:ss
  1332.                          This function limits the amount of Backward change
  1333.                          of the time.   Any change of more  than the speci-
  1334.                          fied time is ignored.  The "-" is optional as  are
  1335.                          the offset fields.
  1336.                               clk r=b
  1337.                          inhibits all backward changes.
  1338.                               CLK R=B::2
  1339.                          only  allows  backward changes  of two  seconds or
  1340.                          less This  might permit CLK to perform adjustments
  1341.                          but effectively stop other backward changes.
  1342.  
  1343.                     R=F+hh:mm:ss
  1344.                          This function limits the  amount of Forward change
  1345.                          of the time.   Any change of more  than the speci-
  1346.                          fied time is ignored.  The "+" is optional as  are
  1347.                          the offset fields.
  1348.                               CLK R=F+1:00:02
  1349.                          limits forward  changes to  1 hour and  2 seconds.
  1350.                          The R=B and  R=F limits do not apply  to the auto-
  1351.                          matic  conversions between  standard and  daylight
  1352.                          savings  time as  these don't actually  change the
  1353.                          time.  The R=B and R=F functions are also indepen-
  1354.                          dent of the R=A function.
  1355.  
  1356.                     R=N
  1357.                          This function reverses the R=A function and inhib-
  1358.                          its No clock changes.   The R=A is independent  of
  1359.                          the R=B and R=F.  You can set backward and forward
  1360.                          limits with R=B  and R=F.   Later you can  inhibit
  1361.  
  1362.  
  1363.  
  1364.                                           18
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.           CLOCK Version 3.47                                 April 10, 1993
  1378.  
  1379.  
  1380.                          all changes with R=A.  When you do R=N, the previ-
  1381.                          ously set R=B and R=F limits again have an effect.
  1382.  
  1383.                     R=R
  1384.                          This function Resets the limits established by R=B
  1385.                          and R=F.  No limits  are in effect after executing
  1386.                          this function.  It has no effect on the R=A mode.
  1387.  
  1388.                     S=C
  1389.                          Sets  both clocks  to  the current  time from  the
  1390.                          calendar  clock.   You  can use  this even  if the
  1391.                          clocks  are  disconnected to  make  the  DOS clock
  1392.                          equal to the calendar clock.  The time zone offset
  1393.                          is set to  00:00:00 and the time zone  name is set
  1394.                          to UTC to indicate that both clocks are set to the
  1395.                          base time.
  1396.  
  1397.                     S=D
  1398.                          Sets both clocks to the  current time from the DOS
  1399.                          clock.  The value from the DOS clock is written to
  1400.                          the  calendar clock.  The time  zone offset is set
  1401.                          to  00:00:00 and the  zone name is  not changed to
  1402.                          indicate that  both clocks  are set to  your local
  1403.                          time.
  1404.  
  1405.                     TZ=...
  1406.                          Sets the DOS clock to the correct local time based
  1407.                          on the value of  the expression following the TZ=.
  1408.                          This  expression  conforms  exactly  to the  POSIX
  1409.                          1003.1 standard  for time zone handling.   CLK as-
  1410.                          sumes that  the calendar clock  currently contains
  1411.                          UTC  (also known  as GMT,  Greenwich, ZULU,  and Z
  1412.                          time).   UTC  ("Universal  Time,  Coordinated"  is
  1413.                          usually spoken as "coordinated universal time") is
  1414.                          the  name of the  international standard time that
  1415.                          is provided  by WWV, WWVH, the  Naval Observatory,
  1416.                          and NIST as well as many other services around the
  1417.                          world.    Most  Unix(r) systems  also  support  TZ
  1418.                          although  many only  partially  support the  POSIX
  1419.                          standard.   See  the  notes later  for a  complete
  1420.                          description of the TZ= function.
  1421.  
  1422.                          You  can  put  the  CLK  TZ=...  command  in  your
  1423.                          AUTOEXEC.BAT file.  You should put it prior to any
  1424.                          other statements  that may create or  update files
  1425.  
  1426.                                         ____________________
  1427.  
  1428.           Unix is a registered trademark of Unix Systems Laboratories.
  1429.  
  1430.                                           19
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.           CLOCK Version 3.47                                 April 10, 1993
  1444.  
  1445.  
  1446.                          or you run  the risk of having  confusing times in
  1447.                          your  file  directory (MAKE  could  get especially
  1448.                          confused.).   If you provide a  TZ= function, your
  1449.                          system  will automatically  adjust to  the correct
  1450.                          time zone every  time you boot.  Note  that no at-
  1451.                          tempt is made to change between daylight and stan-
  1452.                          dard  time  except  when  you  execute CLK  TZ=...
  1453.                          Adjusting on the fly is very dangerous.  Many pro-
  1454.                          grams can  produce incorrect results  or even cor-
  1455.                          rupt your  data if time  takes a big  step forward
  1456.                          and are  even more  likely to do  so if  time runs
  1457.                          backward.  See section 2.2 for a discussion of the
  1458.                          TZ= format.
  1459.  
  1460.                          NOTE:  If you  use the TZ=  function and also  use
  1461.                          WINDOWS, you  will need to  modify your SYSTEM.INI
  1462.                          file.   The SYSTEM.INI file is found  in your WIN-
  1463.                          DOWS  directory.  WINDOWS performs a function very
  1464.                          similar to the C=R  function, but WINDOWS uses the
  1465.                          BIOS  to go  directly  to the  hardware clock  and
  1466.                          hence bypasses CLOCK.SYS.  The result will usually
  1467.                          be your time changing everytime you enter WINDOWS.
  1468.                          Fortunately  you can  avoid  that by  editing  the
  1469.                          SYSTEM.INI file.  In the SYSTEM.INI file, find the
  1470.                          line that looks like:
  1471.                          [386Enh]
  1472.                          Immediately  after that  line or  anywhere  in the
  1473.                          [386Enh] section, insert a line that looks like:
  1474.                          SyncTime=false.
  1475.  
  1476.                     W=-back,+forward
  1477.                          The W= function is  used to establish Warning lim-
  1478.                          its on  the time.   Each time  the W=  function is
  1479.                          processed  (usually from  the  CLK.INI file),  the
  1480.                          current  time and the  previous time are compared.
  1481.                          If the current time  is outside the -back,+forward
  1482.                          range around the previous time, a warning  message
  1483.                          is displayed requiring  you to press  a key.   The
  1484.                          program will  also exit  with an ERRORLEVEL  of 1.
  1485.                          The full form of the W= function is:
  1486.                          W=N-days/hh:mm:ss,+days/hh:mm:ss,
  1487.                               YYYY-MM-DD,hh:mm:ss
  1488.  
  1489.                          The days sub-field is a value from 0 to 250  days.
  1490.                          The  days sub-field  combined with  the time  sub-
  1491.                          fields  gives the maximum interval around the pre-
  1492.                          vious  time  within which  the  current  time must
  1493.  
  1494.  
  1495.  
  1496.                                           20
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.           CLOCK Version 3.47                                 April 10, 1993
  1510.  
  1511.  
  1512.                          fall.  The previous date  and time follow the sec-
  1513.                          ond comma.  For example,
  1514.                               clk w=-0/00:00:02,+91
  1515.                          will  establish a  range of  minus two  seconds to
  1516.                          plus 91 days.   The first time you  use this func-
  1517.                          tion nothing will happen  except that CLK will add
  1518.                          the current date and time to the command and store
  1519.                          it in the CLK.INI file.  The next time you use  if
  1520.                          from  the CLK.INI  file  with CLK /I,  the current
  1521.                          date  and time  will be  compared to  the previous
  1522.                          date and time and the range.  If the current  time
  1523.                          is outside  the range, a message  is displayed and
  1524.                          CLK pauses.
  1525.  
  1526.                          The sign characters and  all of the sub-fields are
  1527.                          optional.  Missing sub-fields are treated as zero.
  1528.                          The particular separators are not important except
  1529.                          for the  commas.   Any non-digit character  can be
  1530.                          used for the other separators.   The time and date
  1531.                          fields are  appended to  the function by  CLK when
  1532.                          the CLK.INI  file is written and  are the previous
  1533.                          time to which the next comparison will be made.  A
  1534.                          typical  function might  be  W=,31.   This command
  1535.                          will  display a  warning whenever  time has  moved
  1536.                          backwards  at all  or has  moved forwards  by more
  1537.                          than 31 days since the last time you used CLK  /I.
  1538.                          If you use CLK /I (see below) in your AUTOEXEC.BAT
  1539.                          file,  this is  very likely  to detect  a miss-set
  1540.                          clock or bad clock battery.  Yet it won't generate
  1541.                          a  message on  every  boot. You  will only  get an
  1542.                          "unnecessary" message  if it has been  more than a
  1543.                          month since you last used the PC.
  1544.  
  1545.                          If the  "N" character (or "n") appears immediately
  1546.                          after the "=", CLK does not pause and wait for you
  1547.                          to press a key after printing the warning message.
  1548.                          The "N" allows you to use  CLK in a .BAT file  and
  1549.                          check for the warning  with the IF ERRORLEVEL com-
  1550.                          mand.
  1551.  
  1552.                     /B
  1553.                          The B option  tells CLK to remain  in command mode
  1554.                          even if no other functions or options are present.
  1555.                          The  /B in  itself performs  no operation,  but it
  1556.                          avoids CLK going into  full-screen mode if all you
  1557.                          want to do is display the current status (e.g., in
  1558.                          a .BAT file).
  1559.  
  1560.  
  1561.  
  1562.                                           21
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.           CLOCK Version 3.47                                 April 10, 1993
  1576.  
  1577.  
  1578.                     /I[,C]
  1579.                     or
  1580.                     /Ifile[,C]
  1581.                          The  I option tells  CLK to read  the CLK.INI file
  1582.                          (or "file" if that  is given) for additional func-
  1583.                          tions.  These functions are usually A=, L=, and W=
  1584.                          functions that were previously written to the file
  1585.                          by CLK.   You may add any other  functions (but no
  1586.                          options) to the file and they will be processed as
  1587.                          if you had entered them at the end of the  command
  1588.                          line.  If  you don't specify  "file" or you  don't
  1589.                          give a path as  part of "file",  CLK will use  the
  1590.                          directory which  contains CLK.EXE.   Thus the  de-
  1591.                          fault  is to  use  CLK.INI in  the directory  that
  1592.                          contains CLK.EXE.  
  1593.  
  1594.                          If you enter an A=, L=, M=,  or W= function or CLK
  1595.                          finds them in the  file, the file will be  updated
  1596.                          with  the new  values  for the  current time  when
  1597.                          appropriate.   If  an adjustment  is made,  the L=
  1598.                          function  will reflect  the date  and time  of the
  1599.                          latest adjustment.   CLK  will update or  create a
  1600.                          CLK.INI  file even if you  don't use the /I option
  1601.                          if you use the A=, L=, M=, or W= functions  on the
  1602.                          command line.
  1603.  
  1604.                          It is  very useful to store your standard TZ=, C=,
  1605.                          and R= functions  in the CLK.INI file.   Then your
  1606.                          AUTOEXEC.BAT  file can  simply  contain  a CLK  /I
  1607.                          command  to set  your  clocks into  their standard
  1608.                          modes, adjust  the time,  and check for  bad clock
  1609.                          values.   You  can also reestablish  your standard
  1610.                          modes after changes with the  same command entered
  1611.                          from the DOS prompt or a .BAT file.
  1612.  
  1613.                          The file  may be hidden and still be updated with-
  1614.                          out error.   However, to update  a read-only file,
  1615.                          you must  add ,C to the  end of the option.   This
  1616.                          indicates  that CLK  may Change the  attributes of
  1617.                          the file in order to update it.  CLK will  restore
  1618.                          the original attributes.   System files may not be
  1619.                          updated.
  1620.  
  1621.                     /M[,C]
  1622.                     or
  1623.                     /Mfile[,C]
  1624.                          The M option is  identical to the I  option except
  1625.                          that only the M= function lines are read  from the
  1626.  
  1627.  
  1628.                                           22
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.           CLOCK Version 3.47                                 April 10, 1993
  1642.  
  1643.  
  1644.                          file.   Its primary  use is  internal to  CLK when
  1645.                          processing an  M= function from  the command line.
  1646.                          You may also use /Mfile to specify the location of
  1647.                          the  file when entering  M= values.   You may also
  1648.                          use  the M  option to  cause recalculation  of the
  1649.                          adjustment factor at any time (e.g., after editing
  1650.                          the file).
  1651.  
  1652.                     /P
  1653.                     or
  1654.                     /PN
  1655.                          Controls the use  of password  protection of  mode
  1656.                          changes.  When you use /P, CLK will ask you  for a
  1657.                          new password.  It will then ask you to repeat  the
  1658.                          password to ensure that you entered what you want.
  1659.                          It does not display the password as  you enter it.
  1660.                          The password is then passed to CLOCK.SYS and pass-
  1661.                          word protection  is enabled.   On future  calls to
  1662.                          CLOCK.SYS, you  will be asked for  the password if
  1663.                          protection is enabled.  You may use /PN to disable
  1664.                          password protection, but you will have  to provide
  1665.                          the current password  to do so.  If  used with the
  1666.                          /S feature, the password protection will remain in
  1667.                          effect even across reboots.  /P should be the last
  1668.                          field on a CLK command line.
  1669.  
  1670.                     /S
  1671.                     or
  1672.                     /Sfile
  1673.                          Saves the current copy  of CLOCK.SYS as it resides
  1674.                          in memory.  If  you do not  specify the file,  the
  1675.                          memory version is written to file CLOCK.NEW in the
  1676.                          same directory that  contains CLK.EXE.  While  you
  1677.                          may  directly overwrite  the  file CLOCK.SYS,  you
  1678.                          should be  very careful doing so  as whatever your
  1679.                          current  state is  will  take effect  on the  next
  1680.                          boot.
  1681.  
  1682.                          PLEASE   MAKE  A  BACKUP  COPY  of  your  original
  1683.                          CLOCK.SYS before replacing  it with a saved  file.
  1684.                          The saved  file does  not do  any probing at  boot
  1685.                          time as  it already knows exactly  what your clock
  1686.                          is.  It does  not need any  parameters on the  de-
  1687.                          vice= line in CONFIG.SYS.
  1688.  
  1689.                          The /S  option may be extremely  useful for anyone
  1690.                          with multiple similar  systems to  maintain.   You
  1691.                          can set  up all  of your options  once on  one ma-
  1692.  
  1693.  
  1694.                                           23
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.           CLOCK Version 3.47                                 April 10, 1993
  1708.  
  1709.  
  1710.                          chine, save those with the /S option, and then use
  1711.                          the  saved file  to  directly install  on all  the
  1712.                          other machines.   If you use  password protection,
  1713.                          no  one can  change  the other  systems except  by
  1714.                          modifying  CONFIG.SYS  to  remove  the loading  of
  1715.                          CLOCK.SYS.
  1716.  
  1717.                          You will still need  to run CLK  as part of  every
  1718.                          boot operation  (e.g., in AUTOEXEC.BAT)  to do any
  1719.                          automatic adjustment (A=  and L= functions), check
  1720.                          for clock failures (W= function), and check to see
  1721.                          whether the clock should  use the standard or day-
  1722.                          light offsets (TZ= function).  These functions are
  1723.                          not processed  automatically by  CLOCK.SYS because
  1724.                          they would increase the  size of the device driver
  1725.                          to an unacceptable limit.
  1726.  
  1727.                     /?
  1728.                          "/?" or  any error will  cause CLK to  display the
  1729.                          usage format.  If you have an error in any  field,
  1730.                          CLK first displays that field.
  1731.  
  1732.                     TZ=:?
  1733.                          "TZ=:?" or any error in a TZ= function that refers
  1734.                          to a  pre-defined time zone causes  CLK to display
  1735.                          all the current  pre-defined time  zone names  and
  1736.                          their associated values.
  1737.  
  1738.  
  1739.           2.2  Format of TZ= Function
  1740.  
  1741.           The format of TZ=... can get quite complicated as the standard is
  1742.           trying to  deal with  all time  zones and  daylight savings  time
  1743.           rules around the world.  The full format is:
  1744.  
  1745.                TZ=:zone
  1746.                or
  1747.                TZ=STD[offset][DAY[offset][,start[/time],end[/time]]]
  1748.  
  1749.           Parameters     zone
  1750.                          The  form TZ=:zone is the  one you are most likely
  1751.                          to need.  CLK knows  the offsets and daylight sav-
  1752.                          ings time rules  for most of the U.S.  and all you
  1753.                          have to supply is the name of your time zone.  The
  1754.                          time zones currently known to CLK are:
  1755.                          EST  Eastern U.S. with automatic daylight
  1756.                          CST  Central U.S. with automatic daylight
  1757.                          MST  Mountain U.S. with automatic daylight
  1758.  
  1759.  
  1760.                                           24
  1761.  
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.           CLOCK Version 3.47                                 April 10, 1993
  1774.  
  1775.  
  1776.                          PST  Pacific U.S. with automatic daylight
  1777.                          HST  Hawaiian with no daylight savings time
  1778.                          MET  Mediterranean with automatic daylight
  1779.  
  1780.                          You can use CLK TZ=:? to display the list of  pre-
  1781.                          defined zone names and their values.
  1782.  
  1783.                          If you would like your favorite time added, please
  1784.                          send me the names,  offset from UTC, and any  day-
  1785.                          light savings  time rules that are  different from
  1786.                          the U.S.  NOTE:  The  names can be composed of any
  1787.                          characters except digits, plus, minus, and  comma.
  1788.                          They can  be up  to 32 characters  long.   Case is
  1789.                          preserved in  the names only for  later display by
  1790.                          CLK.  You can call your zone MyZone.
  1791.  
  1792.                          Case is not important  in matching the zone names.
  1793.                          tz=:cst is  the equivalent of TZ=:CST.   Both will
  1794.                          find the definition of CST.
  1795.                                   
  1796.                     You don't have to wait for me to modify CLK in order to
  1797.                     use your local rules or just try something out.  That's
  1798.                     what the long form is for.
  1799.  
  1800.                     STD
  1801.                          is any  time zone name for standard  time that you
  1802.                          want to use.  See the note above for the rules.
  1803.  
  1804.  
  1805.                     offset
  1806.                          is the difference between  your local time and UTC
  1807.                          and  is expressed as hh[:mm[:ss]] with an optional
  1808.                          leading + or -.  Offsets for times West of  Green-
  1809.                          wich are positive and those East are  negative.  A
  1810.                          24-hour clock  is  used with  times  running  from
  1811.                          00:00:00 to  23:59:59.    Mountain  Standard  time
  1812.                          would be expressed as:
  1813.                               TZ=MST+07:00:00
  1814.                                    or
  1815.                               TZ=MST7
  1816.                          and that's what you would use if you live in  Ari-
  1817.                          zona and  don't  want any  daylight  savings  time
  1818.                          adjustments.
  1819.  
  1820.  
  1821.  
  1822.  
  1823.  
  1824.  
  1825.  
  1826.                                           25
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.           CLOCK Version 3.47                                 April 10, 1993
  1840.  
  1841.  
  1842.                     DAY
  1843.                          is the  time zone name for  daylight savings time.
  1844.                          If  you don't  use daylight  savings time  in your
  1845.                          location, you should not supply this or any of the
  1846.                          following fields.
  1847.  
  1848.                          The offset for daylight time  is in the same  form
  1849.                          as for  standard time.    If you  don't give  this
  1850.                          offset, it  is assumed to  be one hour  later than
  1851.                          standard time.  Thus a more complete specification
  1852.                          of the Eastern time zone would be:
  1853.                               TZ=EST+05:00:00EDT+04:00:00
  1854.                                    or
  1855.                               TZ=EST5EDT4
  1856.                                    or
  1857.                               TZ=EST5EDT     (since  daylight  is one  hour
  1858.                                              later by default)
  1859.  
  1860.                     start
  1861.                          is the day of  the year on which  daylight savings
  1862.                          time starts.  There are three formats that you can
  1863.                          use to give this day.  They are given below.
  1864.  
  1865.                     end
  1866.                          is the  day  of the  year on  which standard  time
  1867.                          starts  again.   Note that  in the  Southern hemi-
  1868.                          sphere it is quite possible for "end" to be earli-
  1869.                          er in  the year  than "start" as  daylight savings
  1870.                          time will include December and January.  end is in
  1871.                          the same  format as start.   Note from  the syntax
  1872.                          above  that you  must provide  end if  you provide
  1873.                          start.
  1874.  
  1875.                     time
  1876.                          is the time  of day that  the change takes  place.
  1877.                          It is  in exactly the same format as offset except
  1878.                          that leading + and  - signs are  not allowed.   If
  1879.                          you do not specify  the time, 02:00:00 is  used as
  1880.                          the default.
  1881.  
  1882.           The day of the year form for start and end may be any of:
  1883.  
  1884.                     Jn
  1885.                          where n is a Julian day of the year from 1 to 365.
  1886.                          This form  does not allow you to refer to February
  1887.                          29.  Day  59 is always  February 28 and Day  60 is
  1888.                          always March 1.  This is  most useful in locations
  1889.  
  1890.  
  1891.  
  1892.                                           26
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.           CLOCK Version 3.47                                 April 10, 1993
  1906.  
  1907.  
  1908.                          where  a particular  calendar date  is used  every
  1909.                          year.
  1910.  
  1911.                     n
  1912.                          where n is a Julian day of the year from 0 to 365.
  1913.                          This form does allow you  to refer to February 29.
  1914.                          January 1  is day  0, February 28  is day  58, and
  1915.                          either February 29 or March 1 is day 59  depending
  1916.                          on whether it is a leap year or not.  Not the most
  1917.                          useful of  forms but  it does deal  with locations
  1918.                          that might  specify February  29 as the  date that
  1919.                          time changes.
  1920.  
  1921.                     Mm.w.d
  1922.                          is used in places like the U.S. that do not speci-
  1923.                          fy a  date, but rather specify  a rule.  m  is the
  1924.                          month  (1  to 12).    d  is the  day  of  the week
  1925.                          (0=Sunday,  1=Monday, ...  6=Saturday).  w  is the
  1926.                          week of the month (1 to 5).  Week 1 indicates  the
  1927.                          first time that day d occurs in that month.   Week
  1928.                          5 indicates  the last time  that day  d occurs  in
  1929.                          that  month whether  it is  the  4th or  5th time.
  1930.                          Thus the U.S. rule is
  1931.                               M4.1.0/02:00:00,M10.5.0/02:00:00
  1932.                          or the first Sunday in April at 2AM until the last
  1933.                          Sunday in October at 2AM.
  1934.  
  1935.           The long form for Central U.S. time is:
  1936.  
  1937.                TZ=CST+06:00:00CDT+05:00:00,M4.1.0/02:00:00,M10.5.0/02:00:00
  1938.                          or
  1939.                TZ=CST6CDT5,M4.1.0/2,M10.5.0/2     (just leaving out zeros)
  1940.                          or
  1941.                TZ=CST6CDT,M4.1.0,M10.5.0          (since 2AM is default)
  1942.                          or
  1943.                TZ=CST6CDT                         (since  the U.S.  rule is
  1944.                                                   the default)
  1945.  
  1946.  
  1947.           2.3  Using CLK
  1948.  
  1949.           The  most common use of CLK will  be to handle your time zone and
  1950.           daylight savings time changes.  You need only do the following:
  1951.  
  1952.           1.   Set your clocks to UTC.
  1953.  
  1954.           2.   Include the following line in your AUTOEXEC.BAT file.
  1955.  
  1956.  
  1957.  
  1958.                                           27
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.           CLOCK Version 3.47                                 April 10, 1993
  1972.  
  1973.  
  1974.                     CLK TZ=:zone   (where  you use  one of  the pre-defined
  1975.                                    zones)
  1976.                          or
  1977.                     CLK TZ=...     (where you define your own rules)
  1978.  
  1979.           That's it.  Everything else will take care of itself.  
  1980.  
  1981.           The only other time you will need to do anything is if you decide
  1982.           to correct your calendar clock to a more accurate time.  You will
  1983.           probably  use TIMESET or one of the  other programs that call the
  1984.           Naval Observatory or NIST or maybe  just your watch that you have
  1985.           set accurately.
  1986.  
  1987.           If you don't want to have to change the configuration of the time
  1988.           setting program,  you may want  to have it  always set UTC  or at
  1989.           least  your local standard time.  If  you want to have it set UTC
  1990.           time, do the following:
  1991.  
  1992.                CLK S=C C=W
  1993.                run your time set program
  1994.                CLK TZ=...     (your normal TZ value)
  1995.  
  1996.           The  C=W in the first  line is only required  if you normally run
  1997.           with the clocks disconnected.
  1998.  
  1999.           Note that if you tell the time set program what your current time
  2000.           zone is, you don't have to do anything unless you have the clocks
  2001.           disconnected.
  2002.  
  2003.           Notes     Leaving your clock on local time                    ________________________________
  2004.                     If you  don't want  to be bothered  with UTC,  CLK will
  2005.                     quite happily work  with your calendar clock set to its
  2006.                     current  value.   For  example, let's  assume that  you
  2007.                     currently have both clocks set to Pacific Standard Time
  2008.                     and you don't  really want to  be bothered changing  to
  2009.                     UTC, but you would like future changes between standard
  2010.                     and daylight  time to  be handled automatically.   Just
  2011.                     use the following statement in AUTOEXEC.BAT:
  2012.                          CLK TZ=PST0PDT
  2013.  
  2014.                     CLK believes whatever you tell it and will quite happi-
  2015.                     ly operate  assuming that  PST is  equal to  UTC.   You
  2016.                     could even  use  CLK with  your calendar  clock set  to
  2017.                     Pacific Daylight Time by using:
  2018.                          CLK TZ=PST1PDT
  2019.  
  2020.                     Avoiding missed days when your PC stays on all night,
  2021.                     and missed years and leap days on type 4 and 6 clocks                    _____________________________________________________
  2022.  
  2023.  
  2024.                                           28
  2025.  
  2026.  
  2027.  
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037.           CLOCK Version 3.47                                 April 10, 1993
  2038.  
  2039.  
  2040.                     If your PC is often left on over  midnight and seems to
  2041.                     miss the change to a new day, use:
  2042.                          CLK C=R TZ=...
  2043.                     in your AUTOEXEC.BAT file to have CLOCK.SYS periodical-
  2044.                     ly read the time and date  from the calendar clock.  If
  2045.                     your clock is a  type 4 or 6 clock that  doesn't update
  2046.                     years automatically and doesn't handle leap  days, then
  2047.                     this setting also ensures that leaving your PC on  over
  2048.                     the end of  a year or across February  29 doesn't cause
  2049.                     you to get the wrong date.
  2050.  
  2051.                     Using CLK.INI to simplify your commands                    _______________________________________
  2052.                     If you always  use the same functions, you  may want to
  2053.                     edit the CLK.INI file that is included in this release.
  2054.                     You can include  your TZ=, C=, and R=  functions in the
  2055.                     file and just use:
  2056.                          CLK /I
  2057.                     in your AUTOEXEC.BAT file.
  2058.  
  2059.                     Adding and subtracting time                    ___________________________
  2060.                     You can pretty much do anything including simple arith-
  2061.                     metic  on your  clocks by  using  the functions  in the
  2062.                     correct sequence.  Let's  say that you  want to add  12
  2063.                     hours to  the current time  in both clocks  because you
  2064.                     inadvertently set  AM  time instead  of PM  time.   The
  2065.                     following function sequence will do that:
  2066.                          CLK TZ=Igoofed-12 S=D TZ=:pst
  2067.  
  2068.                     The TZ=Igoofed-12 (or use any other  name for the zone)
  2069.                     sets your DOS clock to 12 hours later than the calendar
  2070.                     clock.  (Yes, I know that time zone offsets seem  back-
  2071.                     wards  since you subtract them  from the base time, but
  2072.                     that's the way the official standards have them.)
  2073.  
  2074.                     The S=D sets both clocks to the value in the  DOS clock
  2075.                     with a zero offset.
  2076.  
  2077.                     The TZ=:pst should be  replaced by whatever your normal
  2078.                     TZ function is or even by  a /I to pull in your  normal
  2079.                     settings.
  2080.  
  2081.                     If you normally have your clocks disconnected, insert a
  2082.                     C=W function as the first function.
  2083.  
  2084.                     Correcting inadvertent problems                    _______________________________
  2085.                     Just remember that except for the S=D function, CLK and
  2086.                     CLOCK.SYS  always  start with  the assumption  that the
  2087.                     calendar clock  is the base  and do all  their calcula-
  2088.  
  2089.  
  2090.                                           29
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.           CLOCK Version 3.47                                 April 10, 1993
  2104.  
  2105.  
  2106.                     tions from that point.   Thus you can play with TZ  and
  2107.                     other functions as much as you want and always get back
  2108.                     to your normal local time just by using your normal  TZ
  2109.                     command.  The calendar clock will not have been affect-
  2110.                     ed unless you did  something to set  the time or  date.
  2111.                     You can  avoid even that problem  by disconnecting your
  2112.                     clocks  (C=D) or  restricting time  changes (R=A).   In
  2113.                     fact, if you have trouble with some program messing  up
  2114.                     your clocks, try the following:
  2115.  
  2116.                          CLK C=D
  2117.                          execute program
  2118.                          CLK S=C C=W (or C=R) TZ=...  (your normal)
  2119.  
  2120.                     If you  have your  standard C= and  TZ= functions  in a
  2121.                     file, you can simplify this as:
  2122.  
  2123.                          CLK C=D
  2124.                          execute program
  2125.                          CLK S=C /I
  2126.  
  2127.                     You may  even want  to make up  batch files  containing
  2128.                     this sequence to run  those troublesome programs.  Some
  2129.                     games are major causes of problems because they set the
  2130.                     DOS  clock  running faster  or  slower  than normal  to
  2131.                     control the pace  of the game.  As long as they restore
  2132.                     the normal rate when they exit, the above sequence will
  2133.                     eliminate any clock drift problems.
  2134.  
  2135.                     Fast DOS clock drift                    ____________________
  2136.                     Some high-speed communication  programs will also cause
  2137.                     the  DOS clock to run slow by  causing the BIOS to miss
  2138.                     clock interrupts.   Fortunately, a C=R function  should
  2139.                     virtually eliminate problems of this type.
  2140.  
  2141.  
  2142.           2.4  Examples
  2143.  
  2144.                clk A=0.34
  2145.                     sets an adjustment factor of 0.34 seconds per day.  The
  2146.                     A=0.34  function will  be written  to the  CLK.INI file
  2147.                     along with an  L= function with the current  time and a
  2148.                     zero remaining adjustment.  Every time thereafter, that
  2149.                     CLK  is run with the /I option, it will check to see if
  2150.                     it is  time to  adjust the clocks.   About  every third
  2151.                     day, it will add 1 second to both clocks.
  2152.  
  2153.                clk s=c /i
  2154.  
  2155.  
  2156.                                           30
  2157.  
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.           CLOCK Version 3.47                                 April 10, 1993
  2170.  
  2171.  
  2172.                     sets the DOS  clock to the current  calendar clock time
  2173.                     without any time  zone adjustment.   The /i causes  all
  2174.                     functions in the CLK.INI  file to be added.   If one of
  2175.                     them is a tz function, we have corrected the DOS  clock
  2176.                     for any changes  made to it and re-established our time
  2177.                     zone.  This is a good command line to use following a 
  2178.                          clk c=d
  2179.                     and other operations that may have led to an  incorrect
  2180.                     time in the DOS clock.
  2181.  
  2182.                clk c=r tz=:est r=b-00:00:02 r=f+00:00:02
  2183.                     sets CLOCK.SYS  to read the calendar  clock about every
  2184.                     10 seconds  and re-synchronize  the DOS clock  with it;
  2185.                     applies the appropriate Eastern time zone  (standard or
  2186.                     daylight depending  on date); and prohibits  changes to
  2187.                     the clock of more than 2 seconds in either direction.
  2188.  
  2189.  
  2190.           2.5  Errors
  2191.  
  2192.           When errors are detected, CLK prints a message.  It also sets the
  2193.           ERRORLEVEL on each program termination as follows:
  2194.  
  2195.           0    Normal termination or only warning messages.
  2196.  
  2197.           1    Time outside warning range.  Warning issued.
  2198.  
  2199.           2    Error in command line or CLK.INI file functions.  The  func-
  2200.                tion with the error is displayed followed by the appropriate
  2201.                usage rules.
  2202.  
  2203.           3    Internal error or  system error (e.g., unable to open handle
  2204.                to CLOCK.SYS).
  2205.  
  2206.  
  2207.           2.6  Future Enhancements
  2208.  
  2209.           Several enhancements are planned for future releases of CLK.
  2210.  
  2211.                -    Full screen interface that displays  the current status
  2212.                     of all the things that CLK and CLOCK.SYS know and  lets
  2213.                     you change them just by editing the screen.  The rather
  2214.                     clunky command  line interface  needs to remain  as its
  2215.                     compact  function definitions  are what  you want  in a
  2216.                     .BAT file.
  2217.  
  2218.  
  2219.  
  2220.  
  2221.  
  2222.                                           31
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235.           CLOCK Version 3.47                                 April 10, 1993
  2236.  
  2237.  
  2238.                -    Direct dialing of the Naval  Observatory or NIST to get
  2239.                     the correct  time with  automatic creation of  M= func-
  2240.                     tions from the results.
  2241.  
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.  
  2249.  
  2250.  
  2251.  
  2252.  
  2253.  
  2254.  
  2255.  
  2256.  
  2257.  
  2258.  
  2259.  
  2260.  
  2261.  
  2262.  
  2263.  
  2264.  
  2265.  
  2266.  
  2267.  
  2268.  
  2269.  
  2270.  
  2271.  
  2272.  
  2273.  
  2274.  
  2275.  
  2276.  
  2277.  
  2278.  
  2279.  
  2280.  
  2281.  
  2282.  
  2283.  
  2284.  
  2285.  
  2286.  
  2287.  
  2288.                                           32
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.           CLOCK Version 3.47                                 April 10, 1993
  2302.  
  2303.  
  2304.           3  CLKDEMO.EXE
  2305.  
  2306.           A simple version of the CLK program, called CLKDEMO, is  provided
  2307.           in both executable  and source code form.   CLKDEMO only provides
  2308.           support for the C= functions and displaying the clock status.  It
  2309.           is included  to show you  how to add  clock handling to  your own
  2310.           applications.   CLKDEMO  is written  in  C and  is compiled  with
  2311.           Microsoft C 5.1.
  2312.  
  2313.  
  2314.           3.1  CLKDEMO Command Line
  2315.  
  2316.           Syntax    CLKDEMO [C=A|D|R|W] [/?]
  2317.  
  2318.           The functions provided work exactly as  they do in CLK.   CLKDEMO
  2319.           also displays the status and the current times.
  2320.  
  2321.           Since CLKDEMO.EXE is merely a subset of CLK.EXE, it isn't  terri-
  2322.           bly useful as a utility in its own  right.  Its value is that the
  2323.           source  code is  provided.   There  are three  source code  files
  2324.           provided.   CLKDEMO.C is the  main program  and performs  command
  2325.           interpretation and execution.  IOCTL.C is a set of functions that
  2326.           read  and write  the CLOCK$  device  driver using  the DOS  IOCTL
  2327.           functions.  IOCTL.H  is a set  of definitions which  are used  by
  2328.           CLKDEMO and  IOCTL.C.   CLKTYP.H is  a  list of  the clock  types
  2329.           currently supported by these programs.  It is used to display the
  2330.           type.
  2331.  
  2332.  
  2333.  
  2334.  
  2335.  
  2336.  
  2337.  
  2338.  
  2339.  
  2340.  
  2341.  
  2342.  
  2343.  
  2344.  
  2345.  
  2346.  
  2347.  
  2348.  
  2349.  
  2350.  
  2351.  
  2352.  
  2353.  
  2354.                                           33
  2355.  
  2356.  
  2357.  
  2358.  
  2359.  
  2360.  
  2361.  
  2362.  
  2363.  
  2364.  
  2365.  
  2366.  
  2367.           CLOCK Version 3.47                                 April 10, 1993
  2368.  
  2369.  
  2370.           4  IOCTL - API TO CLOCK.SYS
  2371.  
  2372.           IOCTL  is provided to allow you to build your own applications to
  2373.           use  the additional functions that CLOCK.SYS provides.  There are
  2374.           several  APIs  (Application Programming  Interfaces)  provided as
  2375.           part of IOCTL.  These  APIs  are sufficient to perform all of the
  2376.           extended functions.
  2377.  
  2378.           All of  the APIs  are defined  to be directly  callable from  all
  2379.           Microsoft compatible  languages including MASM,  FORTRAN, Pascal,
  2380.           and  BASIC.  Languages  other than  C refer to  the API  names as
  2381.           upper case characters.  Object code versions are provided for the
  2382.           small, medium,  and large  memory models.   These  may be  linked
  2383.           directly with your  applications.  The  object code versions  are
  2384.           SIOCTL.OBJ, MIOCTL.OBJ, and LIOCTL.OBJ for the small, medium, and
  2385.           large models respectively.
  2386.  
  2387.  
  2388.           4.1  Data Structures
  2389.  
  2390.           Data structures are defined in ioctl.h that are used in the calls
  2391.           to the IOCTL functions.
  2392.  
  2393.  
  2394.           /* "modes" holds flags that control the operation of CLOCK.SYS */
  2395.  
  2396.           struct modes {
  2397.               unsigned : 9;
  2398.               unsigned day_light: 1;
  2399.               unsigned disp_24 : 1;
  2400.               unsigned disp_tim : 1;
  2401.               unsigned pw_ena : 1;
  2402.               unsigned disabl : 1;
  2403.               unsigned chk_forw : 1;
  2404.               unsigned chk_back : 1;
  2405.           };
  2406.  
  2407.           /* "off" holds a time offset in hours, minutes, and seconds. */
  2408.  
  2409.           struct off {
  2410.               int hour;
  2411.               int minute;
  2412.               int second;
  2413.           };
  2414.  
  2415.  
  2416.  
  2417.  
  2418.  
  2419.  
  2420.                                           34
  2421.  
  2422.  
  2423.  
  2424.  
  2425.  
  2426.  
  2427.  
  2428.  
  2429.  
  2430.  
  2431.  
  2432.  
  2433.           CLOCK Version 3.47                                 April 10, 1993
  2434.  
  2435.  
  2436.           /* "date_time" is a structure that holds a date and time.    */
  2437.  
  2438.           struct date_time {
  2439.               int year;
  2440.               int month;
  2441.               int day;
  2442.               struct off time;
  2443.               int hsecond;
  2444.           };
  2445.  
  2446.           /* "time_zone" holds a time zone name and offset.   */
  2447.  
  2448.           struct time_zone {
  2449.               struct off offs;
  2450.               unsigned char zone[32];
  2451.           };
  2452.  
  2453.           /* "limit"  is used to  hold the data  that sets time  limits for
  2454.           changes.    */
  2455.  
  2456.           struct limit {
  2457.               struct off back;
  2458.               struct off forward;
  2459.           };
  2460.           /*  "disp" is used to  hold the data  that specifies the location
  2461.           and attributes of the continuous time display.   */
  2462.  
  2463.           struct disp {
  2464.               int x;
  2465.               int y;
  2466.               int attribute;
  2467.           };
  2468.  
  2469.  
  2470.  
  2471.  
  2472.  
  2473.  
  2474.  
  2475.  
  2476.  
  2477.  
  2478.  
  2479.  
  2480.  
  2481.  
  2482.  
  2483.  
  2484.  
  2485.  
  2486.                                           35
  2487.  
  2488.  
  2489.  
  2490.  
  2491.  
  2492.  
  2493.  
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.           CLOCK Version 3.47                                 April 10, 1993
  2500.  
  2501.  
  2502.           /* CLOCK_DATA is the  CLOCK.SYS data that  is returned by  clksta
  2503.           (AKA CLKSTA for FORTRAN,  Pascal, and BASIC languages).   Because
  2504.           we  need to  be language  independent, all of  the data  is word-
  2505.           aligned.  Only  the data types int and character  are used.  Some
  2506.           of the int data is encoded bits or addresses.  */
  2507.  
  2508.           struct CLOCK_DATA {
  2509.               int connected;               /* Connection state          */
  2510.               struct modes mode;           /* Mode bits                 */
  2511.               struct date_time cal_time;   /* Current date and time     */
  2512.               struct time_zone standard;   /* Offset of standard UTC    */
  2513.               struct time_zone daylight;   /* Daylight offset           */
  2514.               struct limit rules;          /* Maximum clock movement    */
  2515.               struct disp display;         /* Time display loc and attr */
  2516.               unsigned char vers[6];       /* CLOCK.SYS version nnn.nn  */
  2517.               int clock_type;              /* Type of clock installed   */
  2518.               int ct_1;                    /* Data for clock type       */
  2519.               int ct_2;
  2520.               int ct_3;
  2521.               int ct_4;
  2522.               unsigned int clock_seg;      /* Segment CLOCK.SYS loaded at*/
  2523.               unsigned int clock_long;     /* Size of CLOCK.SYS          */
  2524.           };
  2525.  
  2526.           This data structure is treated as the following integer array  in
  2527.           the FORTRAN and BASIC languages.
  2528.  
  2529.           BASIC          _____
  2530.                OPTION BASE 1
  2531.                DIM CDATA(66)
  2532.  
  2533.           FORTRAN          _______
  2534.                INTEGER*2 CDATA(66)
  2535.  
  2536.           ARRAY INDEX         CONTENTS                 STRUCTURE ELEMENT          ___________         ________                 _________________
  2537.  
  2538.           CDATA(1)       =    Connection state         connected
  2539.           CDATA(2)       =    Mode bits                mode
  2540.           CDATA(3)       =    Year from calendar clock cal_time.year
  2541.           CDATA(4)       =    Month                    cal_time.month
  2542.           CDATA(5)       =    Day                      cal_time.day
  2543.           CDATA(6)       =    Hour                     cal_time.offs.hour
  2544.           CDATA(7)       =    Minute                   cal_time.offs.minute
  2545.           CDATA(8)       =    Second                   cal_time.offs.second
  2546.           CDATA(9)       =    100th of second          cal_time.hsecond
  2547.           CDATA(10)      =    Standard hours from UTC  standard.offs.hour
  2548.           CDATA(11)      =    Standard minutes         standard.offs.minute
  2549.           CDATA(12)      =    Standard seconds         standard.offs.second
  2550.  
  2551.  
  2552.                                           36
  2553.  
  2554.  
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565.           CLOCK Version 3.47                                 April 10, 1993
  2566.  
  2567.  
  2568.           CDATA(13) -                                  standard.zone
  2569.           CDATA(28)      =    Standard time zone LJSF
  2570.           CDATA(29)      =    Daylight hours from UTC  daylight.offs.hour
  2571.           CDATA(30)      =    Daylight minutes         daylight.offs.minute
  2572.           CDATA(31)      =    Daylight seconds         daylight.offs.second
  2573.           CDATA(32) -                                  daylight.zone
  2574.           CDATA(47)      =    Daylight time zone LJSF
  2575.           CDATA(48)      =    Maximum hours backward   rules.back.hour
  2576.           CDATA(49)      =    Maximum minutes backward rules.back.minute
  2577.           CDATA(50)      =    Maximum seconds backward rules.back.second
  2578.           CDATA(51)      =    Maximum hours forward    rules.forward.hour
  2579.           CDATA(52)      =    Maximum minutes forward  rules.forward.minute
  2580.           CDATA(53)      =    Maximum seconds forward  rules.forward.second
  2581.           CDATA(54)      =    x cursor position        display.x
  2582.           CDATA(55)      =    y cursor position        display.y
  2583.           CDATA(56)      =    attribute                display.attribute
  2584.           CDATA(57) -                                  vers
  2585.           CDATA(59)      =    CLOCK.SYS version LJSF
  2586.           CDATA(60)      =    Clock type               clock_type
  2587.           CDATA(61)      =    I/O address, base memory ct_1
  2588.                               segment, or base year
  2589.           CDATA(62)      =    Read memory offset       ct_2
  2590.           CDATA(63)      =    Write-0 memory offset    ct_3
  2591.           CDATA(64)      =    Write-1 memory offset    ct_4
  2592.           CDATA(65)      =    Segment address          clock_seg
  2593.                               where CLOCK.SYS is loaded
  2594.           CDATA(66)      =    Length of CLOCK.SYS      clock_long
  2595.  
  2596.  
  2597.           4.2  clksta
  2598.  
  2599.           ■  Summary
  2600.  
  2601.           C          _
  2602.  
  2603.           #include <ioctl.h>
  2604.  
  2605.           extern int pascal far clksta(struct CLOCK_DATA *cdata);
  2606.  
  2607.           BASIC          _____
  2608.  
  2609.           OPTION BASE 1
  2610.           DIM CDATA(66)
  2611.  
  2612.           DECLARE FUNCTION CLKSTA%(BYVAL Addr AS INTEGER)
  2613.  
  2614.           STATUS% = CLKSTA(VARPTR(CDATA(1)))
  2615.  
  2616.  
  2617.  
  2618.                                           37
  2619.  
  2620.  
  2621.  
  2622.  
  2623.  
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629.  
  2630.  
  2631.           CLOCK Version 3.47                                 April 10, 1993
  2632.  
  2633.  
  2634.           FORTRAN          _______
  2635.  
  2636.           INTEGER*2 CDATA(66)
  2637.           INTEGER*2 STATUS
  2638.           INTEGER*2 CLKSTA
  2639.  
  2640.           STATUS = CLKSTA(CDATA)
  2641.  
  2642.           ■  Description
  2643.  
  2644.           clksta  returns  all  of the  information  about  CLOCK.SYS in  a
  2645.           structure.  In FORTRAN and  BASIC the structure appears to be  an
  2646.           integer  array.  The above structure declarations can be approxi-
  2647.           mated  in Pascal.  For  a description of the  values of each ele-
  2648.           ment, see the individual APIs below.  The elements not  described
  2649.           as part of the input to other functions are:
  2650.  
  2651.           unsigned char vers[6];      /* CLOCK.SYS version nnn.nn     */
  2652.           int clock_type;             /* Type of clock installed      */
  2653.           int ct_1;                   /* Data for clock type          */
  2654.           int ct_2;
  2655.           int ct_3;
  2656.           int ct_4;
  2657.           unsigned int clock_seg;     /* Segment CLOCK.SYS loaded at  */
  2658.           unsigned int clock_long;    /* Size of CLOCK.SYS            */
  2659.  
  2660.           CDATA(57) -
  2661.           CDATA(59)      =    CLOCK.SYS version LJSF characters
  2662.           CDATA(60)      =    Clock type (see type numbers in appendix B)
  2663.           CDATA(61)      =    I/O  address, base  memory  segment, or  base
  2664.                               year
  2665.           CDATA(62)      =    Read memory offset
  2666.           CDATA(63)      =    Write-0 memory offset
  2667.           CDATA(64)      =    Write-1 memory offset
  2668.           CDATA(65)      =    Segment address at which CLOCK.SYS is loaded
  2669.           CDATA(66)      =    Length in bytes of CLOCK.SYS
  2670.  
  2671.                vers or CDATA(57) - CDATA(59)
  2672.                     Is  the version  number  of the  CLOCK.SYS that  is in-
  2673.                     stalled.   This  is  returned as  a 6-character,  left-
  2674.                     justified, space-filled (LJSF)  character string.   For
  2675.                     example, "3.49  ".
  2676.  
  2677.                clock_type or CDATA(60)
  2678.                     Is the type number of the clock being used.  See Appen-
  2679.                     dix B for the type numbers.
  2680.  
  2681.  
  2682.  
  2683.  
  2684.                                           38
  2685.  
  2686.  
  2687.  
  2688.  
  2689.  
  2690.  
  2691.  
  2692.  
  2693.  
  2694.  
  2695.  
  2696.  
  2697.           CLOCK Version 3.47                                 April 10, 1993
  2698.  
  2699.  
  2700.                ct_1 or CDATA(61)
  2701.                     Is the value of the first clock parameter.  This is the
  2702.                     base I/O  address for I/O  bus clocks, the  base memory
  2703.                     segment address for  memory-mapped clocks, or  the base
  2704.                     year for the AT&T clocks.
  2705.  
  2706.                ct_2 or CDATA(62)
  2707.                     Is the read offset for memory-mapped clocks.
  2708.  
  2709.                ct_3 or CDATA(63)
  2710.                     Is the write 0-bits offset for memory-mapped clocks.
  2711.  
  2712.                ct_4 or CDATA(64)
  2713.                     Is the write 1-bits offset for memory-mapped clocks.
  2714.  
  2715.                clock_seg or CDATA(65)
  2716.                     Is the  segment address  at which CLOCK.SYS  is loaded.
  2717.                     CLOCK.SYS always starts at offset zero in this segment.
  2718.  
  2719.                clock_long or CDATA(66)
  2720.                     Is the length of CLOCK.SYS in bytes.
  2721.  
  2722.           ■ Arguments         cdata
  2723.                                    is a pointer to  a location to place the
  2724.                                    current    state     information    from
  2725.                                    CLOCK.SYS.
  2726.  
  2727.           ■  Return Value
  2728.  
  2729.           If clksta is  successful, the function returns 0.   Otherwise, it
  2730.           returns a non-zero value and _doserrno is set to the  correspond-
  2731.           ing error code.  Possible values are:
  2732.  
  2733.                0001h     Invalid  function.    This  should  indicate  that
  2734.                          CLOCK.SYS is not installed.  It is the error  that
  2735.                          the DOS clock device  driver would return since it
  2736.                          doesn't handle these functions.
  2737.  
  2738.                0005h     Access denied.  Indicates  that DOS would not open
  2739.                          a handle for read access.  You may not have enough
  2740.                          handles available.
  2741.  
  2742.                0006h     Invalid handle.  Should not happen.
  2743.  
  2744.                000Dh     Invalid data.  CLOCK.SYS reported a bad byte count
  2745.                          or otherwise  did not  process the request.   This
  2746.                          should not happen.
  2747.  
  2748.  
  2749.  
  2750.                                           39
  2751.  
  2752.  
  2753.  
  2754.  
  2755.  
  2756.  
  2757.  
  2758.  
  2759.  
  2760.  
  2761.  
  2762.  
  2763.           CLOCK Version 3.47                                 April 10, 1993
  2764.  
  2765.  
  2766.           4.3  setpw
  2767.  
  2768.           ■ Summary
  2769.  
  2770.           C          _
  2771.  
  2772.           #include <ioctl.h>
  2773.  
  2774.           extern void pascal far setpw(unsigned char *pw);
  2775.  
  2776.           BASIC          _____
  2777.  
  2778.           DECLARE SUB SETPW(BYVAL S AS INTEGER)
  2779.  
  2780.           A$ = "MyPasswd"
  2781.           CALL SETPW(SADD(A$))
  2782.  
  2783.           Note  that A$ must be at least 8 characters long.  Only the first
  2784.           8 characters will be used.
  2785.  
  2786.           FORTRAN          _______
  2787.  
  2788.           CHARACTER*8 PW
  2789.  
  2790.           PW = "MyPasswd"
  2791.           CALL SETPW(PW)
  2792.  
  2793.           ■  Description
  2794.  
  2795.           The setpw  function sets  the password to  be used  on subsequent
  2796.           calls to any  of the following functions.   These functions auto-
  2797.           matically  supply  the  most   recent  password  when  they  call
  2798.           CLOCK.SYS.   You need not  ever call setpw  if you are  not using
  2799.           password protection.  CLOCK.SYS will  only check the password  if
  2800.           password protection is enabled through the stmode function.
  2801.  
  2802.           ■ Arguments         pw
  2803.                                    is  a  pointer to  the  password string.
  2804.                                    This string should be exactly 8  charac-
  2805.                                    ters long and must be at least 8 charac-
  2806.                                    ters long.   The password should also be
  2807.                                    LJSF as every  character is significant.
  2808.                                    Case is significant in passwords.
  2809.  
  2810.  
  2811.  
  2812.  
  2813.  
  2814.  
  2815.  
  2816.                                           40
  2817.  
  2818.  
  2819.  
  2820.  
  2821.  
  2822.  
  2823.  
  2824.  
  2825.  
  2826.  
  2827.  
  2828.  
  2829.           CLOCK Version 3.47                                 April 10, 1993
  2830.  
  2831.  
  2832.           ■  Example
  2833.  
  2834.           #include <ioctl.h>
  2835.  
  2836.           main()
  2837.  
  2838.           {
  2839.                   unsigned char pw[9] = "MyPasswd";
  2840.  
  2841.           /* Set password to use on subsequent function calls.  */
  2842.  
  2843.                   setpw(pw);
  2844.  
  2845.           }
  2846.  
  2847.  
  2848.           4.4  connec
  2849.  
  2850.           ■  Summary
  2851.  
  2852.           C          _
  2853.  
  2854.           #include <ioctl.h>
  2855.  
  2856.           extern int pascal far connec(int *conn);
  2857.  
  2858.           BASIC          _____
  2859.  
  2860.           DECLARE FUNCTION CONNEC%(CONN AS INTEGER)
  2861.  
  2862.           STATUS% = CONNEC(CONN)
  2863.  
  2864.           FORTRAN          _______
  2865.  
  2866.           INTEGER*2 CONN, STATUS, CONNEC
  2867.  
  2868.           STATUS = CONNEC(CONN)
  2869.  
  2870.           ■  Description
  2871.  
  2872.           The connec function  provides a means  of setting the  connection
  2873.           state of CLOCK.SYS.
  2874.  
  2875.  
  2876.  
  2877.  
  2878.  
  2879.  
  2880.  
  2881.  
  2882.                                           41
  2883.  
  2884.  
  2885.  
  2886.  
  2887.  
  2888.  
  2889.  
  2890.  
  2891.  
  2892.  
  2893.  
  2894.  
  2895.           CLOCK Version 3.47                                 April 10, 1993
  2896.  
  2897.  
  2898.           ■  Arguments   conn
  2899.                               specifies the new connection mode.  The  val-
  2900.                               ues are:
  2901.                               0 = disconnected (C=D)
  2902.                               1 = connected for writes only (C=W)
  2903.                               2 = connected for  writes and periodic  reads
  2904.                               (C=R)
  2905.                               3 = connected for all operations (C=A)
  2906.  
  2907.  
  2908.           ■ Return Value
  2909.  
  2910.           If  the return  value is zero,  the function  succeeded.   If the
  2911.           return value is non-zero, an error has occurred and _doserrno  is
  2912.           set to the corresponding error code.  Possible values are:
  2913.  
  2914.                0001h     Invalid  function.    This  should  indicate  that
  2915.                          CLOCK.SYS is  not installed.  It is the error that
  2916.                          the DOS clock device  driver would return since it
  2917.                          doesn't handle these functions.
  2918.  
  2919.                0005h     Access denied.  Indicates  that DOS would not open
  2920.                          a handle for read access.  You may not have enough
  2921.                          handles available.
  2922.  
  2923.                0006h     Invalid handle.  Should not happen.
  2924.  
  2925.                000Dh     Invalid data.  CLOCK.SYS reported a bad byte count
  2926.                          or otherwise  did not  process the request.   This
  2927.                          should not happen.
  2928.  
  2929.           ■  Example
  2930.  
  2931.           #include <stdio.h>
  2932.           #include <ioctl.h>
  2933.  
  2934.           main()
  2935.           {
  2936.                int conn_write = 1;
  2937.                int status;
  2938.  
  2939.           /* Set clock to connected for writes */
  2940.  
  2941.                status = connec(&conn_write);
  2942.                if (status)
  2943.                     printf("Error %X in connec\n", status);
  2944.           }
  2945.  
  2946.  
  2947.  
  2948.                                           42
  2949.  
  2950.  
  2951.  
  2952.  
  2953.  
  2954.  
  2955.  
  2956.  
  2957.  
  2958.  
  2959.  
  2960.  
  2961.           CLOCK Version 3.47                                 April 10, 1993
  2962.  
  2963.  
  2964.           4.5  newpw
  2965.  
  2966.           ■  Summary
  2967.  
  2968.           C          _
  2969.  
  2970.           #include <ioctl.h>
  2971.  
  2972.           extern int pascal far newpw(unsigned char *pw);
  2973.  
  2974.           BASIC          _____
  2975.  
  2976.           DECLARE FUNCTION NEWPW%(BYVAL S AS INTEGER)
  2977.  
  2978.           A$ = "MyPasswd"
  2979.           STATUS% = NEWPW(SADD(A$))
  2980.  
  2981.           Note  that A$ must be at least 8 characters long.  Only the first
  2982.           8 characters will be used.
  2983.  
  2984.           FORTRAN          _______
  2985.  
  2986.           CHARACTER*8 PW
  2987.           INTEGER*2 STATUS, NEWPW
  2988.  
  2989.           PW = "MyPasswd"
  2990.           STATUS = NEWPW(PW)
  2991.  
  2992.           ■  Description
  2993.  
  2994.           The  newpw function  sets a  new  password for  CLOCK.SYS.   This
  2995.           function is not  sufficient to enable  password protection.   You
  2996.           must  also use stmode to  turn on password checking.   BE SURE to
  2997.           use newpw before you use stmode to turn on password checking.  If
  2998.           you turn on password checking without first setting the  password
  2999.           to something  that you know,  you will never  be able to  use the
  3000.           CLOCK.SYS functions again until you reboot.
  3001.  
  3002.           ■ Arguments         pw
  3003.                                    is  a pointer  to  the password  string.
  3004.                                    This string should be  exactly 8 charac-
  3005.                                    ters long and must be at least 8 charac-
  3006.                                    ters long.  The  password should also be
  3007.                                    LJSF as every  character is significant.
  3008.                                    Case is significant in passwords.
  3009.  
  3010.           ■ Return Value
  3011.  
  3012.  
  3013.  
  3014.                                           43
  3015.  
  3016.  
  3017.  
  3018.  
  3019.  
  3020.  
  3021.  
  3022.  
  3023.  
  3024.  
  3025.  
  3026.  
  3027.           CLOCK Version 3.47                                 April 10, 1993
  3028.  
  3029.  
  3030.           If  the return value  is zero,  the function  succeeded.   If the
  3031.           return value is non-zero, an error has occurred and _doserrno  is
  3032.           set to the corresponding error code.  Possible values are:
  3033.  
  3034.                0001h     Invalid  function.    This  should  indicate  that
  3035.                          CLOCK.SYS is not installed.   It is the error that
  3036.                          the DOS clock device  driver would return since it
  3037.                          doesn't handle these functions.
  3038.  
  3039.                0005h     Access denied.  Indicates  that DOS would not open
  3040.                          a handle for read access.  You may not have enough
  3041.                          handles available.
  3042.  
  3043.                0006h     Invalid handle.  Should not happen.
  3044.  
  3045.                000Dh     Invalid data.  CLOCK.SYS reported a bad byte count
  3046.                          or otherwise  did not  process the request.   This
  3047.                          should not happen.
  3048.  
  3049.  
  3050.           ■  Example
  3051.  
  3052.           #include <stdio.h>
  3053.           #include <ioctl.h>
  3054.  
  3055.           main()
  3056.  
  3057.           {
  3058.                   unsigned char pw[9] = "MyPasswd";
  3059.                  int status;
  3060.  
  3061.           /* Set new password for CLOCK.SYS  */
  3062.  
  3063.                   status = setpw(pw);
  3064.                  if (status)
  3065.                     printf("Error %X in setpw\n", status);
  3066.  
  3067.           }
  3068.  
  3069.  
  3070.           4.6  rstrct
  3071.  
  3072.  
  3073.  
  3074.  
  3075.  
  3076.  
  3077.  
  3078.  
  3079.  
  3080.                                           44
  3081.  
  3082.  
  3083.  
  3084.  
  3085.  
  3086.  
  3087.  
  3088.  
  3089.  
  3090.  
  3091.  
  3092.  
  3093.           CLOCK Version 3.47                                 April 10, 1993
  3094.  
  3095.  
  3096.           ■  Summary
  3097.  
  3098.           C          _
  3099.  
  3100.           #include <ioctl.h>
  3101.  
  3102.           extern int pascal far rstrct(int *bhour, int *bmin, int *bsec,
  3103.               int *fhour, int *fmin, int *fsec);
  3104.  
  3105.           BASIC          _____
  3106.  
  3107.           DECLARE  FUNCTION RSTRCT%(BHOUR%,  BMIN%,  BSEC%, FHOUR%,  FMIN%,
  3108.           FSEC%)
  3109.  
  3110.           FORTRAN          _______
  3111.  
  3112.           INTEGER*2 BHOUR, BMIN, BSEC, FHOUR, FMIN, FSEC
  3113.           INTEGER*2 RSTRCT
  3114.  
  3115.           STATUS = RSTRCT(BHOUR, BMIN, BSEC, FHOUR, FMIN, FSEC)
  3116.  
  3117.           ■  Description
  3118.  
  3119.           The rstrct  function sets backwards  and forwards limits  on time
  3120.           changes.   Any  time changes  that  exceed these  limits will  be
  3121.           ignored.  For example,  if a backward limit of 2  seconds is set,
  3122.           no change that would move the clock backwards more than 2 seconds
  3123.           will be processed.  Setting the limits protects you agains keying
  3124.           in a  bad time and  agains programs that may  incorrectly set the
  3125.           time.  Yet you  can still change  the time within the  prescribed
  3126.           limits.  For  example, you may set a backward  limit of 2 seconds
  3127.           to permit CLK to adjust the time  by up to 2 seconds while inhib-
  3128.           iting any other  backwards changes.  These limits  have no effect
  3129.           on changing between standard  and daylight times  as that is  not
  3130.           really a change in the "time".
  3131.  
  3132.           ■ Arguments         bhour:bmin:bsec
  3133.                                    is the backward limit  in hours, minutes
  3134.                                    and seconds.
  3135.  
  3136.                               fhour:fmin:fsec
  3137.                                    is the forward limit in hours,  minutes,
  3138.                                    and seconds.
  3139.  
  3140.           ■ Return Value
  3141.  
  3142.  
  3143.  
  3144.  
  3145.  
  3146.                                           45
  3147.  
  3148.  
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.  
  3155.  
  3156.  
  3157.  
  3158.  
  3159.           CLOCK Version 3.47                                 April 10, 1993
  3160.  
  3161.  
  3162.           If  the return value  is zero,  the function  succeeded.   If the
  3163.           return value is non-zero, an error has occurred and _doserrno  is
  3164.           set to the corresponding error code.  Possible values are:
  3165.  
  3166.                0001h     Invalid  function.    This  should  indicate  that
  3167.                          CLOCK.SYS is not installed.   It is the error that
  3168.                          the DOS clock device  driver would return since it
  3169.                          doesn't handle these functions.
  3170.  
  3171.                0005h     Access denied.  Indicates  that DOS would not open
  3172.                          a handle for read access.  You may not have enough
  3173.                          handles available.
  3174.  
  3175.                0006h     Invalid handle.  Should not happen.
  3176.  
  3177.                000Dh     Invalid data.  CLOCK.SYS reported a bad byte count
  3178.                          or otherwise  did not  process the request.   This
  3179.                          should not happen.
  3180.  
  3181.  
  3182.           ■  Example
  3183.  
  3184.           #include <stdio.h>
  3185.           #include <ioctl.h>
  3186.  
  3187.           main()
  3188.  
  3189.           {
  3190.                int bhour = 0;
  3191.                int bmin = 0;
  3192.                int bsec = 2;
  3193.                int fhour = 1;
  3194.                int fmin = 0;
  3195.                int fsec = 0;
  3196.                int status;
  3197.  
  3198.           /* Set  time change  limits to  2 seconds  backwards  and 1  hour
  3199.           forwards  */
  3200.  
  3201.                status = rstrct(&bhour, &bmin, &bsec, &fhour, &fmin, &fsec);
  3202.                if (status)
  3203.                     printf("Error %X in rstrct\n", status);
  3204.                else
  3205.                     printf("Time limits set to "
  3206.                          "-%.2d:%.2d:%.2d,+%.2d:%.2d:%.2d\n",
  3207.                          bhour, bmin, bsec, fhour, fmin, fsec);
  3208.           }
  3209.  
  3210.  
  3211.  
  3212.                                           46
  3213.  
  3214.  
  3215.  
  3216.  
  3217.  
  3218.  
  3219.  
  3220.  
  3221.  
  3222.  
  3223.  
  3224.  
  3225.           CLOCK Version 3.47                                 April 10, 1993
  3226.  
  3227.  
  3228.           4.7  stmode
  3229.  
  3230.           ■  Summary
  3231.  
  3232.           C          _
  3233.  
  3234.           #include <ioctl.h>
  3235.  
  3236.           extern int pascal far stmode(struct modes *mode);
  3237.  
  3238.           BASIC          _____
  3239.  
  3240.           DECLARE FUNCTION STMODE%(MODES%)
  3241.  
  3242.           FORTRAN          _______
  3243.  
  3244.           INTEGER*2 MODES
  3245.           INTEGER*2 STMODE
  3246.  
  3247.           STATUS = STMODE(MODES)
  3248.  
  3249.           ■  Description
  3250.  
  3251.           The  stmode function  sets a  variety  of operating  modes.   The
  3252.           argument is  actually a  structure of bits.   Each  bit specifies
  3253.           whether an operating mode is on (1) or off (0).
  3254.  
  3255.           ■ Arguments         modes
  3256.                                    is set  of bits  that specify  operating
  3257.                                    modes.  The bit values are:
  3258.  
  3259.                                    unsigned : 9;            Unused
  3260.                                    unsigned day_light: 1;   0x0200 (512)
  3261.                                    unsigned disp_24 : 1;    0x0400 (1024)
  3262.                                    unsigned disp_tim : 1;   0x0800 (2048)
  3263.                                    unsigned pw_ena : 1;     0x1000 (4096)
  3264.                                    unsigned disabl : 1;     0x2000 (8192)
  3265.                                    unsigned chk_forw : 1;   0x4000 (16384)
  3266.                                    unsigned chk_back : 1;   0x8000 (32768)
  3267.  
  3268.           ■ Return Value
  3269.  
  3270.           If the  return value  is zero,  the function  succeeded.  If  the
  3271.           return value is non-zero, an error has occurred and _doserrno  is
  3272.           set to the corresponding error code.  Possible values are:
  3273.  
  3274.                0001h     Invalid  function.    This  should  indicate  that
  3275.                          CLOCK.SYS is not installed.  It is the  error that
  3276.  
  3277.  
  3278.                                           47
  3279.  
  3280.  
  3281.  
  3282.  
  3283.  
  3284.  
  3285.  
  3286.  
  3287.  
  3288.  
  3289.  
  3290.  
  3291.           CLOCK Version 3.47                                 April 10, 1993
  3292.  
  3293.  
  3294.                          the DOS clock device  driver would return since it
  3295.                          doesn't handle these functions.
  3296.  
  3297.                0005h     Access denied.  Indicates  that DOS would not open
  3298.                          a handle for read access.  You may not have enough
  3299.                          handles available.
  3300.  
  3301.                0006h     Invalid handle.  Should not happen.
  3302.  
  3303.                000Dh     Invalid data.  CLOCK.SYS reported a bad byte count
  3304.                          or otherwise  did not  process the request.   This
  3305.                          should not happen.
  3306.  
  3307.  
  3308.           ■  Example
  3309.  
  3310.           #include <ioctl.h>
  3311.  
  3312.           main()
  3313.  
  3314.           {
  3315.                struct CLOCK_DATA cdata;
  3316.  
  3317.           /* Set daylight savings time.  */
  3318.  
  3319.                clksta(&cdata);            /* Get current mode settings. */
  3320.  
  3321.                cdata.mode.day_light = 1;  /* Turn on daylight */
  3322.  
  3323.                stmode(&cdata.modes);
  3324.           }
  3325.  
  3326.  
  3327.           4.8  stzone
  3328.  
  3329.           ■  Summary
  3330.  
  3331.           C          _
  3332.  
  3333.           #include <ioctl.h>
  3334.  
  3335.           extern int pascal far stzone(int *shour, int *smin, int *ssec,
  3336.               unsigned char sname[32], int *dhour, int *dmin,
  3337.               int *dsec, unsigned char dname[32]);
  3338.  
  3339.  
  3340.  
  3341.  
  3342.  
  3343.  
  3344.                                           48
  3345.  
  3346.  
  3347.  
  3348.  
  3349.  
  3350.  
  3351.  
  3352.  
  3353.  
  3354.  
  3355.  
  3356.  
  3357.           CLOCK Version 3.47                                 April 10, 1993
  3358.  
  3359.  
  3360.           BASIC          _____
  3361.  
  3362.           DECLARE  FUNCTION  STZONE%(SHOUR%,  SMIN%,  SSEC%,  BYVAL  SN  AS
  3363.           INTEGER, DHOUR%, DMIN%, DSEC%, BYVAL DN AS INTEGER)
  3364.  
  3365.           SNAME$ = "32-CHARACTER STANDARD ZONE NAME "
  3366.           DNAME$ = "Daylight savings time zone name "
  3367.  
  3368.           STATUS% = STZONE(6,0,0,SADD(SNAME$),5,0,0,SADD(DNAME$))
  3369.  
  3370.           FORTRAN          _______
  3371.  
  3372.           CHARACTER*32 SNAME, DNAME
  3373.           INTEGER*2 STZONE, STATUS
  3374.  
  3375.           SNAME = "CST"
  3376.           DNAME = "CDT"
  3377.           STATUS = STZONE(6, 0, 0, SNAME, 5, 0, 0, DNAME)
  3378.  
  3379.           ■  Description
  3380.  
  3381.           The stzone function  sets the standard time and  daylight savings
  3382.           time offsets from the  calendar clock and  the standard and  day-
  3383.           light time zone  names or mnemonics.   Note that the  offsets are
  3384.           subtracted from the calendar  clock to get the local  time.  Thus
  3385.           the standard time offset from UTC to EST is 5:0:0.
  3386.  
  3387.           ■ Arguments         SHOUR:SMIN:SSEC
  3388.                                    is the time difference  between the cal-
  3389.                                    endar clock and local standard time.  It
  3390.                                    may be a positive of negative value.  If
  3391.                                    negative, all three values must be nega-
  3392.                                    tive.
  3393.  
  3394.                               SNAME
  3395.                                    is the  standard time zone name  or mne-
  3396.                                    monic.   It must be  a 32-character LJSF
  3397.                                    character  string.   As  with  all other
  3398.                                    character  strings used  by these  func-
  3399.                                    tions,  there  is  no  terminating  NULL
  3400.                                    character as  is usual in C.   The other
  3401.                                    languages  do  not readily  handle  NULL
  3402.                                    terminated strings.   In  C applications
  3403.                                    you may  define the  character array  to
  3404.                                    contain  33  characters,  but  you  must
  3405.                                    ensure that the  NULL character does not
  3406.                                    occur in the first 32 characters.
  3407.  
  3408.  
  3409.  
  3410.                                           49
  3411.  
  3412.  
  3413.  
  3414.  
  3415.  
  3416.  
  3417.  
  3418.  
  3419.  
  3420.  
  3421.  
  3422.  
  3423.           CLOCK Version 3.47                                 April 10, 1993
  3424.  
  3425.  
  3426.                               DHOUR:DMIN:DSEC
  3427.                                    is the time difference  between the cal-
  3428.                                    endar clock  and local  daylight savings
  3429.                                    time.   Whether  the standard  offset or
  3430.                                    the daylight offset is currently used by
  3431.                                    CLOCK.SYS is  controlled by  the setting
  3432.                                    of the day_light mode bit (see stmode).
  3433.  
  3434.                               DNAME
  3435.                                    is the  daylight savings time  zone name
  3436.                                    or  mnemonic.  It must be a 32-character
  3437.                                    LJSF character string.
  3438.  
  3439.           ■ Return Value
  3440.  
  3441.           If the  return value  is zero,  the function  succeeded.   If the
  3442.           return value is non-zero, an error has occurred and _doserrno  is
  3443.           set to the corresponding error code.  Possible values are:
  3444.  
  3445.                0001h     Invalid  function.    This  should  indicate  that
  3446.                          CLOCK.SYS is not installed.  It is the  error that
  3447.                          the DOS clock device  driver would return since it
  3448.                          doesn't handle these functions.
  3449.  
  3450.                0005h     Access denied.  Indicates  that DOS would not open
  3451.                          a handle for read access.  You may not have enough
  3452.                          handles available.
  3453.  
  3454.                0006h     Invalid handle.  Should not happen.
  3455.  
  3456.                000Dh     Invalid data.  CLOCK.SYS reported a bad byte count
  3457.                          or otherwise  did not  process the request.   This
  3458.                          should not happen.
  3459.  
  3460.  
  3461.  
  3462.  
  3463.  
  3464.  
  3465.  
  3466.  
  3467.  
  3468.  
  3469.  
  3470.  
  3471.  
  3472.  
  3473.  
  3474.  
  3475.  
  3476.                                           50
  3477.  
  3478.  
  3479.  
  3480.  
  3481.  
  3482.  
  3483.  
  3484.  
  3485.  
  3486.  
  3487.  
  3488.  
  3489.           CLOCK Version 3.47                                 April 10, 1993
  3490.  
  3491.  
  3492.           ■  Example
  3493.  
  3494.           #include <stdio.h>
  3495.           #include <ioctl.h>
  3496.  
  3497.           main()
  3498.  
  3499.           {
  3500.                unsigned char sname[33] = "PST                    ";
  3501.                unsigned char dname[33] = "PDT                    ";
  3502.                int shour = 8;
  3503.                int smin = 0;
  3504.                int ssec = 0;
  3505.                int dhour = 7;
  3506.                int dmin = 0;
  3507.                int dsec = 0;
  3508.                struct CLOCK_DATA cdata;
  3509.  
  3510.           /* Get current status.   */
  3511.  
  3512.                clksta(&cdata);
  3513.  
  3514.           /* Set time zone to U.S. Pacific time.  */
  3515.  
  3516.                stzone(&shour, &smin, &ssec, sname, &dhour, &dmin, &dsec,
  3517.                    dname);
  3518.  
  3519.           /* Select daylight savings time.  */
  3520.  
  3521.                cdata.mode.day_light = 1;
  3522.                stmode(&cdata.mode);
  3523.           }
  3524.  
  3525.  
  3526.           4.9  tdisp
  3527.  
  3528.           ■  Summary
  3529.  
  3530.           C          _
  3531.  
  3532.           #include <ioctl.h>
  3533.  
  3534.           extern int pascal far tdisp(int *dispx, int *dispy, int *attr);
  3535.  
  3536.  
  3537.  
  3538.  
  3539.  
  3540.  
  3541.  
  3542.                                           51
  3543.  
  3544.  
  3545.  
  3546.  
  3547.  
  3548.  
  3549.  
  3550.  
  3551.  
  3552.  
  3553.  
  3554.  
  3555.           CLOCK Version 3.47                                 April 10, 1993
  3556.  
  3557.  
  3558.           BASIC          _____
  3559.  
  3560.           DECLARE FUNCTION TDISP%(DISPX%, DISPY%, ATTR%)
  3561.  
  3562.           STATUS% = TDISP(72, 0, &H79)
  3563.  
  3564.           FORTRAN          _______
  3565.  
  3566.           INTEGER*2 TDISP, STATUS
  3567.  
  3568.           STATUS = TDISP(0, 72, 0x79)
  3569.  
  3570.           ■  Description
  3571.  
  3572.           The tdisp  function sets  the coordinates  and attribute  for the
  3573.           continuous time  display.   tdisp  does  not start  or  stop  the
  3574.           continuous display nor  does it set the 12-hour  or 24-hour mode.
  3575.           Those are all provided by the stmode function.
  3576.  
  3577.           ■ Arguments         DISPX
  3578.                                    is the x  (horizontal) cursor coordinate
  3579.                                    for  the continuous  time display.   The
  3580.                                    rightmost character on a line is at x=0.
  3581.                                    Be sure to leave enough space at the end
  3582.                                    of the line to accommodate the entire 8-
  3583.                                    chararacter time display.   For example,
  3584.                                    x=72 is  the last position to specify on
  3585.                                    an 80-character line.
  3586.  
  3587.                               DISPY
  3588.                                    is  the y  (vertical) cursor  coordinate
  3589.                                    for the  continuous time  display.   The
  3590.                                    top line on the display is y=0.
  3591.  
  3592.                               ATTR
  3593.                                    is the display attribute  to use for the
  3594.                                    continuous time display.  ATTR is usual-
  3595.                                    ly  expressed as  two hex  digits.   The
  3596.                                    first  (high-order) digit  is the  back-
  3597.                                    ground  color  (0 to  7) and  the second
  3598.                                    digit is the text or foreground color (0
  3599.                                    to  F).  For  example, 0A  would display
  3600.                                    bright  green letters  on a  black back-
  3601.                                    ground.   Background  colors usually  do
  3602.                                    not include  the  bright  colors.    The
  3603.                                    color numbers are:
  3604.  
  3605.  
  3606.  
  3607.  
  3608.                                           52
  3609.  
  3610.  
  3611.  
  3612.  
  3613.  
  3614.  
  3615.  
  3616.  
  3617.  
  3618.  
  3619.  
  3620.  
  3621.           CLOCK Version 3.47                                 April 10, 1993
  3622.  
  3623.  
  3624.                                         0    Black
  3625.                                         1    Blue
  3626.                                         2    Green
  3627.                                         3    Cyan
  3628.                                         4    Red
  3629.                                         5    Magenta
  3630.                                         6    Brown
  3631.                                         7    White
  3632.                                         8    Grey
  3633.                                         9    Bright blue
  3634.                                         A    Bright green
  3635.                                         B    Brigth cyan
  3636.                                         C    Bright red
  3637.                                         D    Bright magenta
  3638.                                         E    Yellow
  3639.                                         F    Bright White
  3640.  
  3641.           ■ Return Value
  3642.  
  3643.           If the  return value  is zero,  the function succeeded.   If  the
  3644.           return value is non-zero, an error has occurred and _doserrno  is
  3645.           set to the corresponding error code.  Possible values are:
  3646.  
  3647.                0001h     Invalid  function.    This  should  indicate  that
  3648.                          CLOCK.SYS is not installed.  It is  the error that
  3649.                          the DOS clock device  driver would return since it
  3650.                          doesn't handle these functions.
  3651.  
  3652.                0005h     Access denied.  Indicates  that DOS would not open
  3653.                          a handle for read access.  You may not have enough
  3654.                          handles available.
  3655.  
  3656.                0006h     Invalid handle.  Should not happen.
  3657.  
  3658.                000Dh     Invalid data.  CLOCK.SYS reported a bad byte count
  3659.                          or otherwise  did not  process the request.   This
  3660.                          should not happen.
  3661.  
  3662.  
  3663.  
  3664.  
  3665.  
  3666.  
  3667.  
  3668.  
  3669.  
  3670.  
  3671.  
  3672.  
  3673.  
  3674.                                           53
  3675.  
  3676.  
  3677.  
  3678.  
  3679.  
  3680.  
  3681.  
  3682.  
  3683.  
  3684.  
  3685.  
  3686.  
  3687.           CLOCK Version 3.47                                 April 10, 1993
  3688.  
  3689.  
  3690.           ■  Example
  3691.  
  3692.           #include <stdio.h>
  3693.           #include <ioctl.h>
  3694.  
  3695.           main()
  3696.  
  3697.           {
  3698.                struct CLOCK_DATA cdata;
  3699.                int dispx = 72;
  3700.                int dispy = 0;
  3701.                int attr = 0x79;
  3702.  
  3703.           /* Get current CLOCK.SYS modes.  */
  3704.  
  3705.                clksta(&cdata);
  3706.  
  3707.           /* Turn on 12-hour display at end of top line of screen. 
  3708.              Use bright blue text on a white backgroun.          */
  3709.  
  3710.                tdisp(&dispx, &dispy, &attr);
  3711.                cdata.mode.disp_tim = 1;
  3712.                cdata.mode.disp_24 = 0;
  3713.                stmode(&cdata.mode);
  3714.  
  3715.           }
  3716.  
  3717.  
  3718.  
  3719.  
  3720.  
  3721.  
  3722.  
  3723.  
  3724.  
  3725.  
  3726.  
  3727.  
  3728.  
  3729.  
  3730.  
  3731.  
  3732.  
  3733.  
  3734.  
  3735.  
  3736.  
  3737.  
  3738.  
  3739.  
  3740.                                           54
  3741.  
  3742.  
  3743.  
  3744.  
  3745.  
  3746.  
  3747.  
  3748.  
  3749.  
  3750.  
  3751.  
  3752.  
  3753.           CLOCK Version 3.47                                 April 10, 1993
  3754.  
  3755.  
  3756.           5  CLOCK.SYS - ASSEMBLY LANGUAGE API
  3757.  
  3758.           CLOCK.SYS has  a couple of additional  APIs (Application Program-
  3759.           ming Interfaces) that are  not present in  the normal DOS  CLOCK$
  3760.           device driver.  These  interfaces are provided  by the DOS  IOCTL
  3761.           (Input/Output  of ConTroL  data) functions.   The  Output Control
  3762.           Data to Character Device  function is used  to set new  operating
  3763.           values for CLOCK.SYS  for the C=, D=, R=,  TZ=, and /P functions.
  3764.           The Input Control Data from Character Device function is used  to
  3765.           get the current status  and the date and  time from the  calendar
  3766.           clock.
  3767.  
  3768.  
  3769.           5.1  Opening the CLOCK$ Device
  3770.  
  3771.           In order  to use  the additional APIs  provided by  CLOCK.SYS you
  3772.           must  open a handle  to the  CLOCK$ device driver.   You  do this
  3773.           using the  DOS  INT 21H  Open  File with  Handle  (3DH)  function
  3774.           specifying read-write access.  You then use the handle to  invoke
  3775.           the other functions.  Sample assembly language is:
  3776.                MOV  AX,3D00H            ; Open with read and write access
  3777.                MOV  DX,OFFSET filename  ; Pointer to "CLOCK$" ASCIIZ string
  3778.                                         ; DS:DX must point to the string
  3779.                INT  21H                 ; Call DOS function handler
  3780.           ;    AX contains the handle on return if carry flag is not set.
  3781.  
  3782.  
  3783.           5.2  Sending New Values to CLOCK.SYS
  3784.  
  3785.           To change the  state of CLOCK.SYS, you use  the Send Control Data
  3786.           to  Character Device  (4403H) DOS  function.   You  send data  to
  3787.           specify the connection  type, modes, time zone offsets and names,
  3788.           restrictions, continuous display information, and  password.  You
  3789.           may send any combination of these  in any order.  You must always
  3790.           send  the current  password as the  first 8  bytes.   If password
  3791.           checking  is not  enabled, it  doesn't  matter what  the 8  bytes
  3792.           contain, but you must still send the 8 bytes.
  3793.  
  3794.           The data  stream  that you  send  to CLOCK.SYS  consists  of  the
  3795.           current password followed by a selection index, the data for that
  3796.           selection, another selection index, its data, and so on.
  3797.  
  3798.  
  3799.  
  3800.  
  3801.  
  3802.  
  3803.  
  3804.  
  3805.  
  3806.                                           55
  3807.  
  3808.  
  3809.  
  3810.  
  3811.  
  3812.  
  3813.  
  3814.  
  3815.  
  3816.  
  3817.  
  3818.  
  3819.           CLOCK Version 3.47                                 April 10, 1993
  3820.  
  3821.  
  3822.           The selection  indices and the  data stream associated  with each
  3823.           one are:
  3824.  
  3825.           INDEX     DATA ITEMS     COMMENTS          _____     __________     ________
  3826.  
  3827.           1         connected      two  byte   integer  (0 : C=D,  1 : C=W,
  3828.                                    2 : C=R, 3 : C=A)
  3829.  
  3830.           2         mode           two byte  integer (see stmode  for a de-
  3831.                                    scription of the bits)
  3832.  
  3833.           3         standard       time_zone structure for standard time
  3834.                     daylight       time_zone structure for daylight time
  3835.  
  3836.           4         rules          limits structure
  3837.  
  3838.           5         display        disp structure
  3839.  
  3840.           6         password       8 bytes LJSF of new password
  3841.  
  3842.           Sample assembly language to send new information to CLOCK.SYS:
  3843.  
  3844.           curpw     DB   8 dup(?)       ; Current password
  3845.                     DW   1              ; Change connection
  3846.                     DW   2              ;  to C=R
  3847.                     DW   4              ; Change limits
  3848.                     DW   0,0,2,1,0,0    ;  to R=B-::2,F+1
  3849.                     DW   6              ; Set new password
  3850.                     DB   "MyPasswd"     ;  to MyPasswd (case is important)
  3851.                     DW   2              ; Change modes
  3852.                     DW   0D000H         ;  to enable limits and password
  3853.                                         ;  also sets standard time and 
  3854.                                         ;  no display
  3855.           count     equ $-curpw         ; Length to send
  3856.                ...
  3857.                     MOV  AX,4403H       ; Send control data function
  3858.                     MOV  BX,handle      ; Value returned from open
  3859.                     MOV  CX,count       ; Value = number of bytes to send
  3860.                     MOV  DX,OFFSET curpw ; Location of bytes to be sent
  3861.                                         ; DS:DX must point to the buffer
  3862.                     INT  21H            ;
  3863.           ; OK if carry not set.  CX will equal bytes actually taken.
  3864.  
  3865.  
  3866.  
  3867.  
  3868.  
  3869.  
  3870.  
  3871.  
  3872.                                           56
  3873.  
  3874.  
  3875.  
  3876.  
  3877.  
  3878.  
  3879.  
  3880.  
  3881.  
  3882.  
  3883.  
  3884.  
  3885.           CLOCK Version 3.47                                 April 10, 1993
  3886.  
  3887.  
  3888.           5.3  Getting Current Status of CLOCK.SYS
  3889.  
  3890.           To get the current  status and time, you use  the Receive Control
  3891.           Data from Character Device (4402H) function.  You can read all of
  3892.           the CLOCK_DATA  structure or  any smaller amount  of it  that you
  3893.           need, but you can only read starting at the beginning
  3894.  
  3895.           Sample assembly language for reading the clock status is:
  3896.  
  3897.                MOV  AX,440CH            ; Read control data function
  3898.                MOV  BX,handle           ; Value returned from open
  3899.                MOV  CX,count            ; Number of bytes to read
  3900.                MOV  DX,OFFSET buffer    ; Location to store the data
  3901.                                         ; DS:DX must point to the buffer
  3902.                INT  21H                 ; Call DOS
  3903.           ; Data returned if carry not set.
  3904.           ; CX will contain the actual number of bytes transferred.
  3905.  
  3906.  
  3907.  
  3908.  
  3909.  
  3910.  
  3911.  
  3912.  
  3913.  
  3914.  
  3915.  
  3916.  
  3917.  
  3918.  
  3919.  
  3920.  
  3921.  
  3922.  
  3923.  
  3924.  
  3925.  
  3926.  
  3927.  
  3928.  
  3929.  
  3930.  
  3931.  
  3932.  
  3933.  
  3934.  
  3935.  
  3936.  
  3937.  
  3938.                                           57
  3939.  
  3940.  
  3941.  
  3942.  
  3943.  
  3944.  
  3945.  
  3946.  
  3947.  
  3948.  
  3949.  
  3950.  
  3951.           CLOCK Version 3.47                                 April 10, 1993
  3952.  
  3953.  
  3954.           APPENDIX A:  DEFINITION OF SHAREWARE
  3955.  
  3956.           Shareware  distribution  gives users  a  chance  to try  software
  3957.           before buying  it. If  you try a  Shareware program  and continue
  3958.           using  it,  you are  expected  to  register. Individual  programs
  3959.           differ  on  details --  some  request  registration while  others
  3960.           require it, some specify a maximum trial period.  With  registra-
  3961.           tion, you get anything  from the simple  right to continue  using
  3962.           the software to an updated program with printed manual.
  3963.  
  3964.           Copyright laws  apply to both Shareware  and commercial software,
  3965.           and the copyright holder retains all rights, with a few  specific
  3966.           exceptions as  stated below.  Shareware authors are  accomplished
  3967.           programmers, just  like commercial authors, and  the programs are
  3968.           of comparable  quality. (In both  cases, there are  good programs
  3969.           and bad ones!) The main difference  is in the method of distribu-
  3970.           tion.  The author  specifically  grants  the  right to  copy  and
  3971.           distribute the software, either to all and sundry or to a specif-
  3972.           ic group.  For example,  some authors require  written permission
  3973.           before a commercial disk vendor may copy their Shareware.
  3974.  
  3975.           Shareware is a  distribution method, not a type  of software. You
  3976.           should  find  software  that  suits your  needs  and  pocketbook,
  3977.           whether it's commercial or  Shareware. The Shareware system makes
  3978.           fitting your needs easier,  because you can  try before you  buy.
  3979.           And because the  overhead is low, prices are  low also. Shareware
  3980.           has the  ultimate money-back  guarantee -- if  you don't  use the
  3981.           product, you don't pay for it.
  3982.  
  3983.           DISCLAIMER - AGREEMENT
  3984.  
  3985.           Users of CLOCK  must accept this disclaimer of  warranty:  "CLOCK
  3986.           is supplied  as is.   The  author disclaims  all warranties,  ex-
  3987.           pressed or implied, including, without limitation, the warranties
  3988.           of merchantability and of  fitness for any  purpose.  The  author
  3989.           assumes no liability for  damages, direct or consequential, which
  3990.           may result from the use of CLOCK."
  3991.  
  3992.           CLOCK is a  "shareware program" and is  provided at no charge  to
  3993.           the  user for  evaluation.   Feel  free  to  share it  with  your
  3994.           friends, but please  do not give  it away altered  or as part  of
  3995.           another system.   The essence of "user-supported"  software is to
  3996.           provide  personal computer  users with  quality software  without
  3997.           high prices,  and yet  to  provide incentive  for programmers  to
  3998.           continue  to develop  new products.    If you  find this  program
  3999.           useful  and find  that you are  using CLOCK  and continue  to use
  4000.           CLOCK after a reasonable trial period, you must make a  registra-
  4001.           tion payment of $10 to Ronald Q. Smith.  The $10 registration fee
  4002.  
  4003.  
  4004.                                           58
  4005.  
  4006.  
  4007.  
  4008.  
  4009.  
  4010.  
  4011.  
  4012.  
  4013.  
  4014.  
  4015.  
  4016.  
  4017.           CLOCK Version 3.47                                 April 10, 1993
  4018.  
  4019.  
  4020.           will license  one copy  for use  on any one  computer at  any one
  4021.           time.  For a registration fee of $25, I will immediately send you
  4022.           the latest version of  CLOCK including the  source code and  this
  4023.           document as a WordPerfect 5.1 file.   You may use the source code
  4024.           for your own maintenance  of CLOCK or as a learning  tool for any
  4025.           software that you  develop.  You may  not use all or  part of the
  4026.           source code in any software that you develop or release to others
  4027.           without the permission of Ronald Q. Smith.
  4028.  
  4029.           You must  treat this software  just like a  book.  An  example is
  4030.           that this software may be used by any number of people and may be
  4031.           freely moved from one  computer location to  another, so long  as
  4032.           there is no  possibility of it  being used at one  location while
  4033.           it's being used at another.  Just as a book cannot be read by two
  4034.           different persons at the same time.
  4035.  
  4036.           Commercial users of CLOCK must register and pay for their  copies
  4037.           of  CLOCK within 30 days  of first use or  their license is with-
  4038.           drawn.    Site-License arrangements  may  be  made by  contacting
  4039.           Ronald Q. Smith.
  4040.  
  4041.           Anyone distributing CLOCK for any kind of remuneration must first
  4042.           contact Ronald Q. Smith at the address below for authorization.
  4043.  
  4044.           You are encouraged to pass a  copy of CLOCK along to your friends
  4045.           for evaluation.  Please encourage them to register their copy  if
  4046.           they  find that  they  can use  it.   All  registered users  will
  4047.           receive a copy of the latest version of the CLOCK system.
  4048.  
  4049.           Send the fees and any inquiries to:
  4050.  
  4051.                          Ronald Q. Smith
  4052.                          11 Black Oak Road
  4053.                          North Oaks, MN 55127-6204
  4054.  
  4055.           You may also contact me via CompuServe mail at userid  71620,514.
  4056.           I will be  happy to respond to  any problems and  suggestions for
  4057.           future capabilities.
  4058.  
  4059.           You may register CLOCK through the CompuServe Shareware Registra-
  4060.           tion program.  CLOCK.SYS is found under registration ID 104.  The
  4061.           fee for  registering through  CompuServe is  $12 (to  cover their
  4062.           charge) and will be added directly to your CompuServe bill.
  4063.  
  4064.  
  4065.  
  4066.  
  4067.  
  4068.  
  4069.  
  4070.                                           59
  4071.  
  4072.  
  4073.  
  4074.  
  4075.  
  4076.  
  4077.  
  4078.  
  4079.  
  4080.  
  4081.  
  4082.  
  4083.           CLOCK Version 3.47                                 April 10, 1993
  4084.  
  4085.  
  4086.           APPENDIX B:  CLOCK TYPES
  4087.  
  4088.  
  4089.           B.1  Type 0 - PC/AT
  4090.  
  4091.           IBM PC/AT and  all fully compatible  PCs.   Most versions of  DOS
  4092.           fully  support this  clock interface  without a  separate driver.
  4093.           Use CLOCK.SYS to provide support for CLK.EXE and CLKDEMO.EXE.  If
  4094.           you don't  need the  extra functions of  CLK, you  probably don't
  4095.           need CLOCK.SYS.  However,  there were a couple  of late 8088  PCs
  4096.           that adopted  the PC/AT  clock standard but  did not  provide the
  4097.           PC/AT recognition  sentinel.   DOS will not  find the  clock, but
  4098.           CLOCK.SYS will.
  4099.  
  4100.           Amstrad PC1521DD systems use this type of clock.
  4101.                           
  4102.           Automatic  determination checks  location F000:FFFE  for the  hex
  4103.           value FC.
  4104.  
  4105.           BIOS  calls are used to read and write the clock values which are
  4106.           usually stored  in the CMOS  RAM along  with other  configuration
  4107.           information.  The primary interfaces are:
  4108.                           
  4109.                Get Date: MOV  AH,4
  4110.                          INT  1AH
  4111.                               Returns the  year in CX and month  and day in
  4112.                               DX in  BCD format (e.g., a  hex display would
  4113.                               show:  CX=1991, DX=1009 for October 9, 1991).
  4114.  
  4115.                Set Date: MOV  AH,5
  4116.                               Load CX and DX as above for Get Date
  4117.                          INT  1AH
  4118.  
  4119.                Get Time: MOV  AH,2
  4120.                          INT  1AH
  4121.                               Returns hours  and minutes in CX  and seconds
  4122.                               in DH in BCD format.   May also return 100ths
  4123.                               of seconds in DL  (e.g., CX=2359, DX=5900 for
  4124.                               1 second before midnight).
  4125.  
  4126.                Set Time: MOV  AH,3
  4127.                               Load CX and DX as for Get Time
  4128.                          INT  1AH
  4129.  
  4130.  
  4131.  
  4132.  
  4133.  
  4134.  
  4135.  
  4136.                                           60
  4137.  
  4138.  
  4139.  
  4140.  
  4141.  
  4142.  
  4143.  
  4144.  
  4145.  
  4146.  
  4147.  
  4148.  
  4149.           CLOCK Version 3.47                                 April 10, 1993
  4150.  
  4151.  
  4152.           B.2  Type 1 - Zenith Z-18x portables, Supersport 20
  4153.  
  4154.           Automatic determination  checks location  F000:FFFA for  the two-
  4155.           byte hex value 4D32 ("M2").
  4156.  
  4157.           BIOS calls are used to read and write the clock.
  4158.  
  4159.                Get Date: MOV  AH,2
  4160.                          INT  1AH
  4161.                               Returns CX=year  (1980 - 2079) in  binary and
  4162.                               DH=month, DL=day.  All  values are binary.  A
  4163.                               hex display of the above date would look like
  4164.                               CX=7C7, DX=A09.
  4165.  
  4166.                Set Date: MOV  AH,3
  4167.                               Load CX and DX as for Get Date.
  4168.                          INT  1AH
  4169.  
  4170.                Get Time: MOV  AH,4
  4171.                          INT  1AH
  4172.                               Returns CH=hours, CL=minutes,  DH=seconds.  A
  4173.                               hex display would show: CX=173B, DX=3B00.
  4174.  
  4175.                Set Time: MOV  AH,5
  4176.                               Load CX and DX as for Get Time.
  4177.                          INT  1AH
  4178.  
  4179.  
  4180.           B.3  Type 2 - Various Zenith Data System PCs.
  4181.  
  4182.           Automatic  determination  looks  at location  F000:800A  for  the
  4183.           pattern 00,F0,"ZDS".
  4184.  
  4185.                Get Date: MOV  AH,2AH
  4186.                          INT  1AH
  4187.                               Returns CX and DX as for type 1.
  4188.  
  4189.                Set Date: MOV  AH,2BH
  4190.                               Load CX and DX as for type 1.
  4191.                          INT  1AH
  4192.  
  4193.                Get Time: MOV  AH,2CH
  4194.                          INT  1AH
  4195.                               Returns CX and DX as for type 1.
  4196.  
  4197.                Set Time: MOV  AH,2DH
  4198.                               Load CX and DX as for type 1.
  4199.                          INT  1AH
  4200.  
  4201.  
  4202.                                           61
  4203.  
  4204.  
  4205.  
  4206.  
  4207.  
  4208.  
  4209.  
  4210.  
  4211.  
  4212.  
  4213.  
  4214.  
  4215.           CLOCK Version 3.47                                 April 10, 1993
  4216.  
  4217.  
  4218.  
  4219.           B.4  Type 3 - Memory-Mapped Clocks
  4220.  
  4221.           Memory-mapped  clock used  on some  Zenith  Data Systems  PCs and
  4222.           other similar clocks including  many slot-less or no-slot clocks.
  4223.           The  SMT (Systems  Manufacturing Technology)  No-Slot  clocks are
  4224.           supported by this type.
  4225.  
  4226.           Automatic determination  is to  attempt to  read the  clock.   If
  4227.           values other than all 0FFH or  0 are obtained, this clock type is
  4228.           chosen.  All known segments and offsets are tried.
  4229.  
  4230.           Several  different memory  mapping approaches  are used  and many
  4231.           different  address possibilities  are  supported.   In general  a
  4232.           segment address in the ROM region (C800H through FFFFH) is  used.
  4233.           Offsets from that segment  address are used  to read bits,  write
  4234.           zero bits, and  write one bits.  Documentation  may specify those
  4235.           segments and  addresses in several  forms.  For  example, segment
  4236.           F000 with offset F002 is the same as segment FF00 with offset 2.
  4237.  
  4238.           Each memory reference reads  or writes a single bit.  Read opera-
  4239.           tions are  used  for all  references  with separate  offsets  for
  4240.           reading a bit, writing a zero bit, and writing a one bit.
  4241.  
  4242.           Clock segments and addresses currently probed include:
  4243.  
  4244.               ╔═══════╤═════════╤════════╤═════╤═════╤═════╤════════╗
  4245.               ║SEGMENT│WRITE 0  │WRITE 1 │READ │DECR │LAST │VENDOR  ║
  4246.               ╟───────┼─────────┼────────┼─────┼─────┼─────┼────────╢
  4247.               ║F000   │ F002    │F003    │F004 │0000 │F000 │(Zenith)║
  4248.               ╟───────┼─────────┼────────┼─────┼─────┼─────┼────────╢
  4249.               ║FE00   │    2    │   3    │   5 │0080 │C800 │SMT     ║
  4250.               ╟───────┼─────────┼────────┼─────┼─────┼─────┼────────╢
  4251.               ║FE00   │    0    │   2    │   8 │0080 │C800 │SMT     ║
  4252.               ╚═══════╧═════════╧════════╧═════╧═════╧═════╧════════╝
  4253.  
  4254.           Multiple address  combinations may be  tried for each  clock pat-
  4255.           tern.   The DECR value is  subtracted from the SEGMENT  value for
  4256.           another attempt  at probing  until the value  equals LAST.   Note
  4257.           that like  the SEGMENT address,  DECR and  LAST are  in units  of
  4258.           paragraphs (16-bytes).  Thus DECR of 80 is equivalent to 800H  or
  4259.           2048 bytes.
  4260.  
  4261.           When the  addresses used by a memory-mapped  clock are determined
  4262.           by  probing, the segment  and read address is  displayed.  As the
  4263.           read  address varies  the  most from  one  clock manufacturer  to
  4264.           another it is a good indication of the type of clock found.
  4265.  
  4266.  
  4267.  
  4268.                                           62
  4269.  
  4270.  
  4271.  
  4272.  
  4273.  
  4274.  
  4275.  
  4276.  
  4277.  
  4278.  
  4279.  
  4280.  
  4281.           CLOCK Version 3.47                                 April 10, 1993
  4282.  
  4283.  
  4284.           Data is stored in BCD in  bytes that you construct by shifting in
  4285.           the bits.  The most important data bytes are: 
  4286.                0 = Hundredths of seconds
  4287.                1 = Seconds
  4288.                2 = Minutes
  4289.                3 = hours
  4290.                5 = days
  4291.                6 = months
  4292.                7 = years mod 1980
  4293.  
  4294.  
  4295.           B.5  Type 4 - Direct Register I/O Bus Clock
  4296.  
  4297.           Many add-in clocks on  expansion boards use  this type of  clock.
  4298.           Some built-in clocks in  PCs are also  accessed similarly.   This
  4299.           clock was used on many AST  Research I/O boards for 8088 PCs such
  4300.           as  the Six-Pack Plus,  IO Plus,  etc.  Also  used on  some Tandy
  4301.           systems (e.g., 1200HD) and the Vendex Turbo-888-XT.
  4302.  
  4303.           Automatic determination is to attempt to read, complement, write,
  4304.           re-read, and re-complement one  of the registers.   If the  first
  4305.           value  read and the  re-complemented second value  are equal, the
  4306.           register exists and is presumed to be the clock.
  4307.  
  4308.           See also the description for types 6  and 7.  If you aren't  sure
  4309.           which variant you have, specify type 8 and automatic probing will
  4310.           determine if it  is really a type 4,  6, or 7.   For the greatest
  4311.           chance of detecting  the correct clock type, supply  the base I/O
  4312.           address if at all possible.
  4313.  
  4314.           NOTE:   If the clock is not correctly initialized (e.g., you have
  4315.           just replaced the  battery), CLOCK.SYS must initialize it so that
  4316.           the counters will  start working.  CLOCK.SYS  determines that the
  4317.           clock has been previously initialized by looking  at register 14H
  4318.           (see  B below).  If register B contains the value 0DEH, the clock
  4319.           is  presumed to be initialized.  If not, CLOCK.SYS will clear all
  4320.           the registers to zero and start the counters running.  While this
  4321.           form  of  checking for  initialization  was  commonly used,  your
  4322.           previous software may have  used a different method.  If  so, the
  4323.           first time  you run CLOCK.SYS  your date and  time may be  set to
  4324.           zero (1980-1-1 00:00:00).   If that happens, just  enter the date
  4325.           and time.  It should work OK after that without resetting to zero
  4326.           on further boots.
  4327.  
  4328.           Each clock register is implemented as a separate I/O register ad-
  4329.           dress.  Clock  base I/O addresses  of 240H, 2C0H, 300H,  and 340H
  4330.           are supported by automatic probing.  Similar clocks at other base
  4331.           I/O addresses  are supported  by specifying type  4 and  the base
  4332.  
  4333.  
  4334.                                           63
  4335.  
  4336.  
  4337.  
  4338.  
  4339.  
  4340.  
  4341.  
  4342.  
  4343.  
  4344.  
  4345.  
  4346.  
  4347.           CLOCK Version 3.47                                 April 10, 1993
  4348.  
  4349.  
  4350.           address.  The address range  used is the base  plus 0 through 1FH
  4351.           (e.g., 2C0H through 2DFH).
  4352.                           
  4353.           Important registers are (using 2C0 as the example):
  4354.                           
  4355.                2C1  =  100ths of seconds 
  4356.                2C2  =  seconds 
  4357.                2C3  =  minutes 
  4358.                2C4  =  hours 
  4359.                2C6  =  days
  4360.                2C7  =  months
  4361.                2C9  =  month last time clock was read/set 
  4362.                2CA  =  years
  4363.                2CB  =  initialized flag (0DEH if initialized)
  4364.                2D4  =  Status
  4365.                               
  4366.           All values are in BCD.  That means that each register consists of
  4367.           two 4-bit nybbles (a nybble is to a nibble as a byte is to a bite
  4368.           - I haven't seen this used recently,  but as a bit of trivia, the
  4369.           first IBM 360 principles of operation manuals used that term  and
  4370.           that spelling -  at least in a  draft copy that we got  in 1965).
  4371.           Each nybble contains  one decimal digit of the value.   Years are
  4372.           mod 1980 (i.e., 0 means 1980, 99 means 2079).
  4373.  
  4374.           Since these  clocks do not keep  the year and do  not handle leap
  4375.           years for you, CLOCK.SYS does the necessary calculations to  keep
  4376.           the year  correctly maintained  and to adjust  the date  for leap
  4377.           days.  The  clocks do  provide a  couple of  memory locations  in
  4378.           which CLOCK.SYS maintains  the year and previous month.   As long
  4379.           as you boot your system before a full year has passed,  CLOCK.SYS
  4380.           will correctly maintain the date.
  4381.  
  4382.  
  4383.           B.6  Type 5 - Mitsubishi 8088 PCs
  4384.  
  4385.           These were sold by Sperry as the PC-1 and  PC/HT, by Leading Edge
  4386.           as the Model D, by Mitsubishi, and others.
  4387.  
  4388.           Automatic  determination checks location F000:FFB3 for the string
  4389.           "MITSUBISHI".   Later Mitsubishi PCs which used a different clock
  4390.           had the same string  at a different location.  We  hope all early
  4391.           versions had it at this location.
  4392.  
  4393.  
  4394.  
  4395.  
  4396.  
  4397.  
  4398.  
  4399.  
  4400.                                           64
  4401.  
  4402.  
  4403.  
  4404.  
  4405.  
  4406.  
  4407.  
  4408.  
  4409.  
  4410.  
  4411.  
  4412.  
  4413.           CLOCK Version 3.47                                 April 10, 1993
  4414.  
  4415.  
  4416.           BIOS functions are used to access the clock.
  4417.  
  4418.                Get Date: MOV  AH,4
  4419.                          INT  1AH
  4420.                               Returns  CL=year  mod   1980,  DH=month,  and
  4421.                               DL=day all  in binary.  Also  sets AL=0FFH if
  4422.                               the clock  is busy and the  request should be
  4423.                               retried.
  4424.  
  4425.                Set Date: MOV  AH,5
  4426.                               Load CL, DX as for Get Date.
  4427.                          INT  1AH
  4428.                               Returns AL=0FFH if busy.
  4429.  
  4430.                Get Time: MOV  AH,2
  4431.                          INT  1AH
  4432.                               Returns  CH=hour,  CL=minute, DH=second,  and
  4433.                               AL=status.  AL=0FFH  means busy.   AL=0 means
  4434.                               24-hour mode.   AL=1 means AM  and AL=3 means
  4435.                               PM.
  4436.  
  4437.                Set Time: MOV  AH,3
  4438.                               Load AL, CX, DH as for Get Time.
  4439.                          INT  1AH
  4440.                               Returns AL=0FFH if busy.
  4441.  
  4442.           NOTE:  Some early Mitsubishi PCs came with fixed disk controllers
  4443.           that were not DOS compatible.  In addition to the clock modifica-
  4444.           tions, the DOS for those systems also handled the disk controller
  4445.           variant.  If you have such  a PC, CLOCK.SYS is not sufficient  to
  4446.           enable  you to go  above DOS  level 3.2.   You will  also need to
  4447.           replace your fixed disk controller.  I strongly suggest that  you
  4448.           create a boot floppy for your current DOS level before you try to
  4449.           install your new DOS level.  Then boot your new DOS from a floppy
  4450.           disk, do SYS C: and copy COMMAND.COM to C:, then try a disk boot.
  4451.           If the disk boot fails, boot the floppy you just created and do a
  4452.           SYS C:  and copy COMMAND.COM to  C: to restore your  old DOS ver-
  4453.           sion.  At that point, your best bet is to simply give up and stay
  4454.           with DOS 3.2. If you want to proceed, you must replace your fixed
  4455.           disk controller.
  4456.  
  4457.           If  SYS C:  gives you an  error status that  indicates that there
  4458.           isn't room  for the  new DOS version  (very possible  when moving
  4459.           from 3.2 to 3.3 or above), you must backup your entire fixed disk
  4460.           and use FORMAT C:/S to place the  new version of DOS on the disk.
  4461.           While  this is a hassle, at least if  your PC won't boot from the
  4462.           disk, the fall-back approach is identical.  There will be room to
  4463.           put DOS 3.2 or earlier back on the fixed disk.
  4464.  
  4465.  
  4466.                                           65
  4467.  
  4468.  
  4469.  
  4470.  
  4471.  
  4472.  
  4473.  
  4474.  
  4475.  
  4476.  
  4477.  
  4478.  
  4479.           CLOCK Version 3.47                                 April 10, 1993
  4480.  
  4481.  
  4482.  
  4483.           B.7  Type 6 - Indirect Register I/O Bus Clock
  4484.  
  4485.           Used on AST  Research boards and others.  Typically uses the same
  4486.           I/O base  address as  type 4.   However  the clock  registers are
  4487.           selected by sending the register address to the base I/O  address
  4488.           and then  reading or writing  data at the  base I/O address  + 1.
  4489.           The internal register numbers and their contents are the same  as
  4490.           for type 4.
  4491.  
  4492.           Automatic determination by probing the address  register.  If the
  4493.           low-order bit is one, it may be this type of clock or type 7.  We
  4494.           then look  further to determine if  it is type 7.   If you aren't
  4495.           sure which  type of clock you have but believe it is type 4, 6 or
  4496.           7, specify type 8 and automatic probing will detect which variant
  4497.           it  is.  If at all possible  specify the base I/O address as that
  4498.           will increase  the likelihood  that the correct  determination is
  4499.           made.
  4500.  
  4501.           I/O  addresses used  are (again  using  2C0 as  the example  base
  4502.           address):
  4503.  
  4504.                2C0    =  Address register.  Writing a value to this address
  4505.                          selects the internal register to read or write.
  4506.                2C1    =  Data register.   Reading or writing  this address,
  4507.                          reads or writes  the internal register  previously
  4508.                          selected by writing 2C0.
  4509.  
  4510.           The internal register numbers are (the values to write to 2C0):
  4511.  
  4512.                 1  =  100ths of seconds
  4513.                 2  =  seconds
  4514.                 3  =  minutes
  4515.                 4  =  hours
  4516.                 6  =  days
  4517.                 7  =  months
  4518.                 9  =  month last time date was read or written
  4519.                 A  =  year
  4520.                 B  =  initialization flag
  4521.                14  =  status
  4522.                           
  4523.           Other processing is the same as type 4.
  4524.  
  4525.  
  4526.  
  4527.  
  4528.  
  4529.  
  4530.  
  4531.  
  4532.                                           66
  4533.  
  4534.  
  4535.  
  4536.  
  4537.  
  4538.  
  4539.  
  4540.  
  4541.  
  4542.  
  4543.  
  4544.  
  4545.           CLOCK Version 3.47                                 April 10, 1993
  4546.  
  4547.  
  4548.           B.8  Type 7 - Complex I/O Bus Clock
  4549.  
  4550.           Used  on AST Research boards and others.  Typically uses the same
  4551.           base I/O address as  types 4 and 6.   Type 7 uses a more  complex
  4552.           register  access sequence than type 6.  Type 7 can be detected by
  4553.           looking to see if the value in register D has bit 1 (value=2) set
  4554.           which type  6 will not.  If  you aren't sure which  type of clock
  4555.           you have  but believe it is  type 4, 6  or 7, specify type  8 and
  4556.           automatic  probing will  detect which variant  it is.   If at all
  4557.           possible specify the  base I/O address as that  will increase the
  4558.           likelihood that the correct determination is made.
  4559.  
  4560.           The base I/O address is used  as an address register and the base
  4561.           + 1 as  a data register.  This  is the same as for  clock type 6.
  4562.           However, the internal  registers and the form of  the commands is
  4563.           quite  different.  The  primary difference  is that  the internal
  4564.           registers only hold four  bits of data each.  Thus  each internal
  4565.           register represents a single decimal digit.
  4566.  
  4567.           The I/O addresses are used as follows (using 2C0 as an example):
  4568.  
  4569.                2C0     = Address register.  The  number of an internal reg-
  4570.                          ister  plus 80H is written  to this I/O address to
  4571.                          select an internal register.
  4572.  
  4573.                2C1     = Data register.   Four  bits  of data  are read  or
  4574.                          written  using this  I/O  address from  or to  the
  4575.                          internal register  previously selected  by writing
  4576.                          to 2C0.
  4577.  
  4578.           The internal registers are:
  4579.  
  4580.                0  =  Units digit of seconds
  4581.                1  =  Tens digit of seconds
  4582.                2  =  Units digit of minutes
  4583.                3  =  Tens digit of minutes
  4584.                4  =  Units digit of hours
  4585.                5  =  Tens digit of hours
  4586.                6  =  Day of week
  4587.                7  =  Units digit of day of month
  4588.                8  =  Tens digit of day of month
  4589.                9  =  Units digit of month
  4590.                A  =  Tens digit of month
  4591.                B  =  Units digit of year
  4592.                C  =  Tens digit of year
  4593.                D  =  Function register
  4594.                E  =  Function register
  4595.                F  =  Function register
  4596.  
  4597.  
  4598.                                           67
  4599.  
  4600.  
  4601.  
  4602.  
  4603.  
  4604.  
  4605.  
  4606.  
  4607.  
  4608.  
  4609.  
  4610.  
  4611.           CLOCK Version 3.47                                 April 10, 1993
  4612.  
  4613.  
  4614.  
  4615.           B.9  Type 8 - Generic I/O Bus Clock
  4616.  
  4617.           Type unknown.  Probe only for types 4, 6, 7, 9, and B.   Use type
  4618.           8 if you are sure that you have an I/O bus clock (i.e., the clock
  4619.           is on an add-in card) but aren't sure whether it is type 4, 6, 7,
  4620.           9, or  B.  If at all possible, supply the base I/O address of the
  4621.           clock as this will greatly increase the likelihood of the correct
  4622.           handling method being chosen.
  4623.  
  4624.  
  4625.           B.10 Type 9 - Quadram I/O Bus Clock
  4626.  
  4627.           This type  was  used  by Quadram  Corporation  on  the  QuadCard,
  4628.           QuadCard II, and QuadCard 512+.  It may have  been used on others
  4629.           as well.
  4630.  
  4631.           Automatic determination checks to see that I/O registers exist at
  4632.           310H or 210H.
  4633.  
  4634.           This clock  used four I/O  control registers and  twelve internal
  4635.           registers.  The I/O registers (using 310H as the example) are:
  4636.  
  4637.                310  =  Data register (used to move data values)
  4638.                311  =  Address register (used to select internal register)
  4639.                312  =  Function register (Read, write, hold counter)
  4640.                313  =  Control register (Enables read or write function)
  4641.  
  4642.  
  4643.  
  4644.  
  4645.  
  4646.  
  4647.  
  4648.  
  4649.  
  4650.  
  4651.  
  4652.  
  4653.  
  4654.  
  4655.  
  4656.  
  4657.  
  4658.  
  4659.  
  4660.  
  4661.  
  4662.  
  4663.  
  4664.                                           68
  4665.  
  4666.  
  4667.  
  4668.  
  4669.  
  4670.  
  4671.  
  4672.  
  4673.  
  4674.  
  4675.  
  4676.  
  4677.           CLOCK Version 3.47                                 April 10, 1993
  4678.  
  4679.  
  4680.           The internal registers are:
  4681.  
  4682.                 0 = Units digit of seconds
  4683.                 1 = Tens digit of seconds
  4684.                 2 = Units digit of minutes
  4685.                 3 = Tens digit of minutes
  4686.                 4 = Units digit of hours
  4687.                 5 = Tens digit of hours - Also uses bit 2 (=4) to  indicate
  4688.                     PM if  in 12-hour mode and bit 3 (=8) to select 24-hour
  4689.                     mode
  4690.                 6 = Day of week (we don't use this)
  4691.                 7 = Units digit of days
  4692.                 8 = Tens digit  of days - Also uses  bit 3 (=8) to indicate
  4693.                     that  this is a  leap year.   This bit  must be  set by
  4694.                     software whenever there is less than 366 days until the
  4695.                     next leap day.  If you  do not boot within that period,
  4696.                     leap day will not be taken.
  4697.                 9 = Units digit of months
  4698.                10 = Tens digit of months
  4699.                11 = Units digit of year mod 1980
  4700.                12 = Tens digit of year mod 1980
  4701.  
  4702.           NOTE:  If you have this type of clock, you  can only set the time
  4703.           to the nearest minute.  Whenever the time is set, the seconds are
  4704.           always  set to  zero.   You  should set  the time  as the  minute
  4705.           changes.  For that reason, you will not want to use the automatic
  4706.           adjustment capability of  CLK with this type of clock  as it will
  4707.           try to set the time to the nearest second.
  4708.  
  4709.  
  4710.           B.11 Type A - AT&T 6300, 6300 PLUS, 6300 WGS
  4711.  
  4712.           Automatic probing  is accomplished by  trying to read  the clock.
  4713.           If the read attempt using the BIOS is  successful (carry flag not
  4714.           set) and the values returned look like a valid time, the clock is
  4715.           assumed to be present.
  4716.  
  4717.           NOTE:  AT&T clocks  do not advance the year on January  1.  It is
  4718.           necessary  to change  the date  at  the beginning  of each  year.
  4719.           Also, AT&T clocks always clear the seconds to zero  when the time
  4720.           is changed.  For  this reason you should always set  the date and
  4721.           time  at the beginning of a minute.   You should also not use the
  4722.           automatic adjustment feature of CLK with these clocks.
  4723.  
  4724.           A base year may be specified on the DEVICE= line.  If it is  not,
  4725.           1992 will be  used.  This  base will be  good for all dates  from
  4726.           1992-1-1 till 1999-12-31.
  4727.  
  4728.  
  4729.  
  4730.                                           69
  4731.  
  4732.  
  4733.  
  4734.  
  4735.  
  4736.  
  4737.  
  4738.  
  4739.  
  4740.  
  4741.  
  4742.  
  4743.           CLOCK Version 3.47                                 April 10, 1993
  4744.  
  4745.  
  4746.           BIOS functions are used with this clock.
  4747.  
  4748.                Get Date: MOV  AH,0FEH
  4749.                          INT  1AH
  4750.                               Returns BX =  Days since base, CH = Hours, CL
  4751.                               = Minutes, DH = Seconds,  DL = 100ths of sec-
  4752.                               onds
  4753.  
  4754.                Set Date: MOV  AH,0FFH
  4755.                          MOV  BX,Days since base
  4756.                          MOV  CH,Hours
  4757.                          MOV  CL,Minutes
  4758.                          MOV  DH,0
  4759.                          MOV  DL,0
  4760.                          INT  1AH
  4761.  
  4762.  
  4763.           B.12 Type B - Hyundai 8088 clock
  4764.  
  4765.           Automatic determination  probes the control registers.   If they,
  4766.           appear to be present, CLOCK tries to read the  clock.  Legal time
  4767.           and date values will select this clock.
  4768.  
  4769.           This clock uses I/O addresses E0H through EFH as follows:
  4770.                E0  =  Units digit of seconds
  4771.                E1  =  Tens digit of seconds
  4772.                E2  =  Units digit of minutes
  4773.                E3  =  Tens digit of minutes
  4774.                E4  =  Units digit of hours
  4775.                E5  =  Tens digit of hours
  4776.                E6  =  Day of week
  4777.                E7  =  Units digit of days
  4778.                E8  =  Tens digit of days
  4779.                E9  =  Units digit of month
  4780.                EA  =  Tens digit of month
  4781.                EB  =  Units digit of year
  4782.                EC  =  Tens digit of year
  4783.                ED  =  Control
  4784.                EE  =  Control
  4785.                EF  =  Control
  4786.  
  4787.  
  4788.  
  4789.  
  4790.  
  4791.  
  4792.  
  4793.  
  4794.  
  4795.  
  4796.                                           70
  4797.  
  4798.  
  4799.  
  4800.  
  4801.  
  4802.  
  4803.  
  4804.  
  4805.  
  4806.  
  4807.  
  4808.  
  4809.           CLOCK Version 3.47                                 April 10, 1993
  4810.  
  4811.  
  4812.           APPENDIX C:  REVISION HISTORY
  4813.  
  4814.           930410 -  Version 3.47: Add MET time zone to list  of pre-defined
  4815.                     time zones (GMT-1).  Document use of D= to resume  last
  4816.                     display.   Fix exit on  TZ=:?.  Add documentation about
  4817.                     modifying SYSTEM.INI when using TZ= in conjunction with
  4818.                     WINDOWS.
  4819.  
  4820.           930403 -  Version 3.46: Fix time  of switch to daylight or  stan-
  4821.                     dard.   It was based on GMT  and should have been based
  4822.                     on local time.
  4823.  
  4824.           930311 -  Version 3.45: Correct M=  adjustment for the pending A=
  4825.                     adjustment.
  4826.  
  4827.           930309 -  Version 3.44: Modified M= to automatically set the date
  4828.                     and time on the L= to the same as the last M= if the L=
  4829.                     is earlier.  It  also sets any remaining adjustment  to
  4830.                     zero.  This  is because the clock  was adjusted exactly
  4831.                     at the point represented by the M=.
  4832.  
  4833.           930306 -  Version  3.43: Fixed bug with M= function not forcing a
  4834.                     read of the  A= functions in CLK.INI and  thus not cor-
  4835.                     rectly displaying the previous and new adjustment.
  4836.  
  4837.           930304 -  Version 3.42: Changed  time moving  backwards logic  to
  4838.                     only look  for earlier  hours.  At  least one  case has
  4839.                     been seen of a program that set the time backward a few
  4840.                     ticks  by  direct calls  on  the BIOS  and  resulted in
  4841.                     CLOCK.SYS advanceing the day.  Now we only  advance the
  4842.                     day if  the time moves backwards an hour or more.  Also
  4843.                     added  the /N option for  CLOCK.SYS that shuts off this
  4844.                     logic  completely if  the  date advances  unexpectedly.
  4845.                     Also fixed a bug in locating the CLK.INI file when  the
  4846.                     A= function is used by itself.
  4847.  
  4848.           930220 -  Version 3.41: Changed timing window prevention logic in
  4849.                     CLOCK.SYS to  control another possible case  of the day
  4850.                     advancing twice over midnight.
  4851.  
  4852.           930212 -  Version 3.40: Added  the M= function  and /M option  to
  4853.                     provide  calculation of the  adjmustment value.   Added
  4854.                     help for all functions and options. Added the /B option
  4855.                     in anticipation  of later support  of full-screen mode.
  4856.                     Added  the ,C flag  on the /I  and /M  options to allow
  4857.                     updating a  read-only file.   Added error  messages for
  4858.                     I/O errors when updating the file.  Fixed timing window
  4859.                     in  CLOCK.SYS that  could  occur  when  the  continuous
  4860.  
  4861.  
  4862.                                           71
  4863.  
  4864.  
  4865.  
  4866.  
  4867.  
  4868.  
  4869.  
  4870.  
  4871.  
  4872.  
  4873.  
  4874.  
  4875.           CLOCK Version 3.47                                 April 10, 1993
  4876.  
  4877.  
  4878.                     display  is operational  that could  cause the  date to
  4879.                     advance unpredictably.
  4880.  
  4881.           930204 -  Version 3.31:  Fixed bug  in CLOCK.SYS with  some clock
  4882.                     types  causing system  lockups or  bad data  to  be re-
  4883.                     turned.
  4884.  
  4885.           930130 -  Version  3.30: Added  support  for a  password and  for
  4886.                     saving  the current  CLOCK.SYS state  as a new  copy of
  4887.                     CLOCK.SYS for  future booting.   Added  continuous time
  4888.                     display.   Changed  API  to support  direct calls  from
  4889.                     BASIC,  FORTRAN, and  Pascal  as well  as  C and  MASM.
  4890.                     Changed status display to be easier to read.
  4891.  
  4892.           930115 -  Version 3.24: Converted document to WordPerfect 5.1 and
  4893.                     rewrote  much  of it.    Provide  document in  standard
  4894.                     release that can either be viewed on-line or printed.
  4895.  
  4896.           930110 -  Version  3.23: Added  support for  R= and  W= commands.
  4897.                     Fixed handling of CLK.INI file so that we don't try  to
  4898.                     update  it if  it is  read only  or is  in  a read-only
  4899.                     sub-directory.   We also  don't update it  if we  can't
  4900.                     find  the [clk]  section as  it may  be  someone else's
  4901.                     file.
  4902.  
  4903.           930106 -  Version 3.22: Fixed  bug in CLK.EXE  that caused it  to
  4904.                     move the CLK.INI file to the root directory.
  4905.  
  4906.           930104 -  Version 3.21: Fixed bug in CLOCK.SYS expecting zero for
  4907.                     100ths of seconds from CMOS clock but some  BIOSs don't
  4908.                     zero  the register.  Fixed bug in CLK with synchroniza-
  4909.                     tion algorithm not correctly waiting for a new second.
  4910.  
  4911.           930102 -  Version 3.20:  Add support for a command file, automat-
  4912.                     ic adjustment, and improved synchronization.  My thanks
  4913.                     to Eric Smith for the ideas that lead to these enhance-
  4914.                     ments.
  4915.  
  4916.           921230 -  Version 3.11:  Simplified logic in CLOCK.SYS for check-
  4917.                     ing if calendar clock should be read.
  4918.  
  4919.           921229 -  Version 3.10: Add support for constant  synchronization
  4920.                     with calendar clock.  Fix bug in calculating dates near
  4921.                     the end of leap years.
  4922.  
  4923.           921226 -  Version 3.02: Recompile CLK.EXE and CLKDEMO.EXE to only
  4924.                     use 8088 instructions.  Version 3.01 inadvertently com-
  4925.  
  4926.  
  4927.  
  4928.                                           72
  4929.  
  4930.  
  4931.  
  4932.  
  4933.  
  4934.  
  4935.  
  4936.  
  4937.  
  4938.  
  4939.  
  4940.  
  4941.           CLOCK Version 3.47                                 April 10, 1993
  4942.  
  4943.  
  4944.                     piled with  80286 instructions  which can lock  up 8088
  4945.                     systems.
  4946.  
  4947.           921221 -  Version 3.01:  Fixed  a couple  of  bugs in  beta  test
  4948.                     version 3.00 with non-PC/AT clocks.  Added logic to CLK
  4949.                     to  display the  pre-defined  time zones  on errors  or
  4950.                     request.
  4951.  
  4952.           921219 -  Version 3.00: Added support for automatic time zone and
  4953.                     daylight savings  time adjustment.   CLOCK.SYS  now has
  4954.                     the ability to  manage the DOS real time  clock and the
  4955.                     battery-protected clock separately.  CLK.EXE is used to
  4956.                     convert a base value  in the battery-protected clock to
  4957.                     a correct local time in the DOS clock.
  4958.  
  4959.           920614 -  Version 2.24: Fixed bug in probing of AT&T 6300 clocks.
  4960.                     Some of the  clocks do not set AL  on successful opera-
  4961.                     tion.
  4962.  
  4963.           920604 -  Version  2.23: Fixed  bug  causing  fall  through  into
  4964.                     memory probing when only I/O probing was wanted.
  4965.  
  4966.           920411 -  Version 2.22: Changed order of probing to probe memory-
  4967.                     mapped clocks  last as they are  being spuriously found
  4968.                     on some Tandy systems.
  4969.  
  4970.           920401 -  Version 2.21:   Changed pattern of  I/O address probing
  4971.                     to probe all possible I/O addresses for one type (e.g.,
  4972.                     4) before trying any  for another type.   Try to  avoid
  4973.                     finding the wrong type.  Added the type B clock to  the
  4974.                     type 8 probe.
  4975.  
  4976.           920328 -  Version 2.20:  Changed order of I/O address probing for
  4977.                     clock types  4,  6, and  7  to avoid,  where  possible,
  4978.                     accessing other  boards.  Most commonly  used I/O clock
  4979.                     addresses, I hope, are now probed first.
  4980.  
  4981.           920322 -  Version 2.19:  Improved probing for I/O clocks to check
  4982.                     that legal values are found in all the  data registers.
  4983.                     Several of  the I/O  clocks use operation  sequences so
  4984.                     much like each other that it is possible to choose  the
  4985.                     wrong one if  we don't actually read the  time and date
  4986.                     and see  if the  values are  legal.   This approach  to
  4987.                     probing may possibly result in not finding a clock that
  4988.                     is present  but that  has been totally  reset.   Such a
  4989.                     clock should  be found  on a  second try  to boot  with
  4990.                     CLOCK.SYS as the counters will have advanced by then.
  4991.  
  4992.  
  4993.  
  4994.                                           73
  4995.  
  4996.  
  4997.  
  4998.  
  4999.  
  5000.  
  5001.  
  5002.  
  5003.  
  5004.  
  5005.  
  5006.  
  5007.           CLOCK Version 3.47                                 April 10, 1993
  5008.  
  5009.  
  5010.           920320 -  Version  2.18:   Added probing  for generic  PC/AT type
  5011.                     clock on systems that don't have the PC/AT signature in
  5012.                     the BIOS.
  5013.  
  5014.           920307 -  Version 2.17:  Added Hyundai 8088 clock.
  5015.  
  5016.           920112 -  Version 2.16:  Added AT&T 6300 clock.
  5017.  
  5018.           920111 -  Version 2.15:  Fixed memory address used by one type of
  5019.                     SMT No-Slot clock.
  5020.  
  5021.           920105 -  Version 2.14:   Added support  for a  wider variety  of
  5022.                     memory mapped clocks including  the SMT (Systems  Manu-
  5023.                     facturing Technology) No-Slot clocks.
  5024.  
  5025.           911208 -  Version 2.13:  Add  probing for Vendex Headstart Turbo-
  5026.                     888-XT system and any other I/O clock at 300H.   Change
  5027.                     I/O clock probing logic to make it less likely to  find
  5028.                     the wrong type by accident.
  5029.  
  5030.           911129 -  Version 2.12:  Fix handling of Quadram clocks (type 9).
  5031.                     They can only set seconds to zero so generate an  error
  5032.                     if anyone tries to set the seconds to any other value.
  5033.  
  5034.           911128 -  Version  2.11:    Fix  bug in  handling  clock  type 9,
  5035.                     Quadram clocks that left  clock turned off after opera-
  5036.                     tions.   Also fix bug  in busy determination  for clock
  5037.                     types 4 and 6 that could result  in a decision that the
  5038.                     clock was not operational.
  5039.  
  5040.           911121 -  Version  2.10:  Add clock types 6 ,7 and 9.  Add type 8
  5041.                     to do specific  probing for the  various I/O bus  clock
  5042.                     types.
  5043.  
  5044.           911109 -  Version 2.05:   Fix  bug in leap  day handling  for I/O
  5045.                     clocks.   Fix bug that caused hung systems when setting
  5046.                     the date or time on Z-18x portables.
  5047.  
  5048.           911026 -  Version 2.04:  Add support for I/O clocks  at addresses
  5049.                     240H  and 340H.    Reduce resident  memory required  by
  5050.                     clock driver  to only that required  for specific clock
  5051.                     type.
  5052.  
  5053.           911021 -  Version  2.03:   Change handling of  new day  flag from
  5054.                     BIOS to  accommodate BIOSs that indicate  multiple days
  5055.                     have passed.
  5056.  
  5057.  
  5058.  
  5059.  
  5060.                                           74
  5061.  
  5062.  
  5063.  
  5064.  
  5065.  
  5066.  
  5067.  
  5068.  
  5069.  
  5070.  
  5071.  
  5072.  
  5073.           CLOCK Version 3.47                                 April 10, 1993
  5074.  
  5075.  
  5076.           911020 -  Version 2.02:  Fix bug in returning date on clock  read
  5077.                     functions.  Added message in automatic determination to
  5078.                     indicate type found.
  5079.  
  5080.           911010  - Version  2.01:     Added  automatic  determination   of
  5081.                     Mitsubishi 8088 PC  clocks.  Fixed handler  to keep the
  5082.                     BIOS  counter set  properly for  programs that  read it
  5083.                     directly.    Also  returns a  finer  granularity  value
  5084.                     (100ths of seconds) on reads.
  5085.  
  5086.           911009  - Version 2.00:   Modified clock driver  to support addi-
  5087.                     tional clock types.  Thanks to Eric Smith (no relation)
  5088.                     for help in finding out how the Zenith PC clock worked.
  5089.  
  5090.           911005  - Version 1.20:  Changed prologue and epilogue to conform
  5091.                     to DOS 5.00  documentation.  Seems to work  OK with DOS
  5092.                     5.0 without the  changes, but we might as  well be con-
  5093.                     sistent to save problems later.
  5094.  
  5095.           910903  - Version 1.10:  Added  display of current date  and time
  5096.                     when initializing.
  5097.  
  5098.           910518  - CLOCK version  1.00.  Initial version  developed at the
  5099.                     request of a  friend with a Sperry PC/HT  who wanted to
  5100.                     move to DOS 4.01.
  5101.  
  5102.           1984    - Write clock device driver  for AST clock for IBM  PC-1.
  5103.                     This serves as the  introduction to what device drivers
  5104.                     and especially the CLOCK$ driver are all about.
  5105.  
  5106.  
  5107.  
  5108.  
  5109.  
  5110.  
  5111.  
  5112.  
  5113.  
  5114.  
  5115.  
  5116.  
  5117.  
  5118.  
  5119.  
  5120.  
  5121.  
  5122.  
  5123.  
  5124.  
  5125.  
  5126.                                           75
  5127.  
  5128.  
  5129.  
  5130.  
  5131.  
  5132.